55
66permissions :
77 packages : write
8+ contents : read
89
910jobs :
1011 build :
1314 - name : Checkout master
1415 uses : actions/checkout@v3
1516
16- - name : Install doctl
17- uses : digitalocean/action-doctl@v2
18- with :
19- token : ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
17+ - name : Set up Docker Buildx
18+ uses : docker/setup-buildx-action@v3
2019
2120 - name : Log in to the Container registry
2221 uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
@@ -28,23 +27,33 @@ jobs:
2827 - name : Build and push Docker image
2928 uses : docker/build-push-action@v6
3029 with :
30+ platforms : linux/arm64
3131 push : true
3232 tags : ghcr.io/apollorion/manifestsio:latest
3333
34- - name : Tag with SHA and push that too
35- run : |
36- TAG=$(echo $GITHUB_SHA | head -c7)
37- docker tag ghcr.io/apollorion/manifestsio:latest ghcr.io/apollorion/manifestsio:${TAG}
38- docker push ghcr.io/apollorion/manifestsio:${TAG}
39-
40- - name : Update deployment file
41- run : TAG=$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|ghcr.io/apollorion/manifestsio:'${TAG}'|' deployment.yaml
34+ - name : Build and push SHA-tagged image
35+ uses : docker/build-push-action@v6
36+ with :
37+ platforms : linux/arm64
38+ push : true
39+ tags : ghcr.io/apollorion/manifestsio:${{ github.sha }}
4240
43- - name : Log in to DigitalOcean
44- run : doctl kubernetes cluster kubeconfig save --expiry-seconds 1200 ${{ secrets.DIGITALOCEAN_CLUSTER_ID }}
41+ - name : Checkout flux repository
42+ uses : actions/checkout@v4
43+ with :
44+ repository : apollorion/flux
45+ ssh-key : ${{ secrets.FLUX_DEPLOY_KEY }}
46+ path : flux-repo
4547
46- - name : Deploy to DigitalOcean Kubernetes
47- run : kubectl apply -f deployment.yaml
48+ - name : Update deployment file in flux repo
49+ run : |
50+ sed -i 's|image: .*|image: ghcr.io/apollorion/manifestsio:${{ github.sha }}|' flux-repo/clusters/home/manifestsio/deployment.yaml
4851
49- - name : Verify deployment
50- run : kubectl -n manifestsio rollout status deployment/manifestsio
52+ - name : Commit and push changes to flux repo
53+ run : |
54+ cd flux-repo
55+ git config --local user.email "[email protected] " 56+ git config --local user.name "GitHub Action"
57+ git add clusters/home/manifestsio/deployment.yaml
58+ git commit -m "Update manifestsio image to ${{ github.sha }}" || exit 0
59+ git push
0 commit comments