loic-go/.forgejo/workflows/pipeline.yml

34 lines
1.3 KiB
YAML
Raw Normal View History

2025-03-28 11:04:34 +00:00
name: CI/CD Pipeline
on: push
2025-03-28 11:04:34 +00:00
env:
FORGEJO_BASE_URL: ${{ vars.FORGEJO_BASE_URL }}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
2025-03-28 11:04:34 +00:00
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
2025-03-28 11:45:10 +00:00
go-version: '1.24'
2025-03-28 11:04:34 +00:00
- name: Build Go Binary
run: go mod tidy && go build -o loic
2025-03-28 11:04:34 +00:00
- name: Build and Push Docker Image
run: |
docker build -t loic:${{ github.sha }} .
echo "$FORGEJO_API_TOKEN" | docker login -u {{ .Identity }} --password-stdin ${{ env.FORGEJO_BASE_URL }}
docker tag loic:${{ github.sha }} ${{ env.FORGEJO_BASE_URL }}/{{ .Identity }}/loic:${{ github.sha }}
2025-03-28 11:47:59 +00:00
docker login -u {{ .Identity }} --password-stdin ${{ secret.PASSWORD }}
2025-03-28 11:04:34 +00:00
docker push ${{ env.FORGEJO_BASE_URL }}/{{ .Identity }}/loic:${{ github.sha }}
2025-03-28 11:47:59 +00:00
# - name: Update Deployment Manifest
# run: |
# sed -i "s|image: .*|image: ${{ env.FORGEJO_BASE_URL }}/{{ .Identity }}/loic:${{ github.sha }}|" k8s/deployment.yaml
# git config --global user.email "ci@edp.local"
# git config --global user.name "CI Bot"
# git add k8s/deployment.yaml
# git commit -m "Update image to ${{ github.sha }}"
# git push
2025-03-28 11:04:34 +00:00
env:
FORGEJO_API_TOKEN: ${{ secrets.FORGEJO_API_TOKEN }}