Skip to content

Commit a72af10

Browse files
authored
Merge pull request #8 from metno/7-add-push-to-github-registry
Push to both ACR and GHCR.
2 parents f922be8 + 4b766e6 commit a72af10

2 files changed

Lines changed: 36 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
- rawdataforecaster
2121
- xmlfrontend
2222
env:
23-
IMAGE: fortiregistry.azurecr.io/${{ matrix.service }}:${{ github.run_id }}
23+
ACR_IMAGE: fortiregistry.azurecr.io/${{ matrix.service }}:${{ github.run_id }}
24+
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/forti-${{ matrix.service }}:${{ github.run_id }}
2425
steps:
2526
- uses: actions/checkout@v4
2627
- name: Login to ACR
@@ -29,10 +30,17 @@ jobs:
2930
registry: fortiregistry.azurecr.io
3031
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
3132
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
33+
- name: Login to GitHub Container Registry
34+
uses: docker/login-action@v4
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
3239
- name: Build and push
3340
run: |
34-
docker build -t $IMAGE -f ${{ matrix.service }}/build/package/Dockerfile .
35-
docker push $IMAGE
41+
docker build -t $ACR_IMAGE -t $GHCR_IMAGE -f ${{ matrix.service }}/build/package/Dockerfile .
42+
docker push $ACR_IMAGE
43+
docker push $GHCR_IMAGE
3644
3745
fortiup:
3846
name: Build fortiup
@@ -46,13 +54,19 @@ jobs:
4654
- name: Create ref slug
4755
id: slug
4856
run: echo "slug=$(echo '${{ github.ref_name }}' | tr '/.' '-')" >> "$GITHUB_OUTPUT"
49-
57+
- name: Login to ACR
58+
uses: docker/login-action@v4
59+
with:
60+
registry: fortiregistry.azurecr.io
61+
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
62+
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
5063
- name: Build image and extract binary
5164
env:
52-
IMAGE: fortiregistry.azurecr.io/fortiup:${{ github.run_id }}
65+
ACR_IMAGE: fortiregistry.azurecr.io/fortiup:${{ github.run_id }}
5366
run: |
54-
docker build -t $IMAGE -f fortiup/build/package/Dockerfile .
55-
docker run --rm --entrypoint cat $IMAGE /usr/local/bin/fortiup > ${{ steps.slug.outputs.slug }}
67+
docker build -t $ACR_IMAGE -f fortiup/build/package/Dockerfile .
68+
docker push $ACR_IMAGE
69+
docker run --rm --entrypoint cat $ACR_IMAGE /usr/local/bin/fortiup > ${{ steps.slug.outputs.slug }}
5670
chmod +x ${{ steps.slug.outputs.slug }}
5771
5872
- name: Upload binary artifact

.github/workflows/devcontainer.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ jobs:
77
devcontainer:
88
name: Build and push devcontainer image
99
runs-on: ubuntu-latest
10+
env:
11+
ACR_IMAGE: fortiregistry.azurecr.io/devcontainer:latest
12+
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/forti-devcontainer:latest
1013
steps:
1114
- uses: actions/checkout@v4
1215
- name: Login to ACR
@@ -15,7 +18,17 @@ jobs:
1518
registry: fortiregistry.azurecr.io
1619
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
1720
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v4
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
1827
- name: Build and push
1928
run: |
20-
docker build -t fortiregistry.azurecr.io/devcontainer:latest -f .devcontainer/Dockerfile .
21-
docker push fortiregistry.azurecr.io/devcontainer:latest
29+
docker build \
30+
-t $ACR_IMAGE \
31+
-t $GHCR_IMAGE \
32+
-f .devcontainer/Dockerfile .
33+
docker push $ACR_IMAGE
34+
docker push $GHCR_IMAGE

0 commit comments

Comments
 (0)