-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 2.29 KB
/
build-push-action.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
68
---
name: Build and Push Docker Images
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.WRITE_PACKAGE_TOKEN }}
- name: Build and push frontend Docker image
id: frontend_build
uses: docker/build-push-action@v6
with:
file: ./container/frontend.dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/frontend:${{ github.sha }}
# - name: Build and push scigateway Docker image
# uses: docker/build-push-action@v6
# id: scigateway_build
# with:
# context: ./container
# file: ./container/scigateway.dockerfile
# push: true
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/scigateway:${{ github.sha }}
- name: Checkout the Gitops repository
uses: actions/checkout@v4
with:
repository: fiaisis/gitops
token: ${{ secrets.GITOPS_STAGING_EDIT_TOKEN }}
- name: Edit the YAML frontend file for staging
uses: mikefarah/[email protected]
with:
cmd: yq e -i '.spec.template.spec.containers[] |= select(.name == "frontend").image = "ghcr.io/fiaisis/frontend@${{ steps.frontend_build.outputs.digest }}"' './components/frontend/envs/staging/frontend.yml'
# - name: Edit the YAML scigateway file for staging
# uses: mikefarah/[email protected]
# with:
# cmd: yq e -i '.spec.template.spec.containers[] |= select(.name == "scigateway").image = "ghcr.io/fiaisis/scigateway@${{ steps.scigateway_build.outputs.digest }}"' './components/scigateway/envs/staging/scigateway.yml'
- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "[CD] Update frontend with this commit ${{ github.event.head_commit.url}}"
git push