-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (65 loc) · 2.29 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Docker
on:
push:
branches:
- "main"
jobs:
build:
name: "Build Frontend"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
file: Dockerfile
tags: |
ghcr.io/csesoc/tech-spire-2022:${{ github.sha }}
ghcr.io/csesoc/tech-spire-2022:latest
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy (CD)
runs-on: ubuntu-latest
needs: [build]
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: csesoc/deployment
token: ${{ secrets.GH_TOKEN }}
- name: Install yq - portable yaml processor
uses: mikefarah/[email protected]
- name: Update deployment
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git config user.name "CSESoc CD"
git config user.email "[email protected]"
git checkout -b update/tech-spire-2022/${{ github.sha }}
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/tech-spire-2022:${{ github.sha }}"' apps/projects/tech-spire-2022/deploy.yml
git add .
git commit -m "feat(tech-spire-2022): update images"
git push -u origin update/tech-spire-2022/${{ github.sha }}
gh pr create --title "feat(tech-spire-2022): update image" --body "Updates the images for the tech-spire-2022 deployment to commit csesoc/tech-spire-2022@${{ github.sha }}." > URL
gh pr merge $(cat URL) --squash -d