Skip to content

Commit 202e4b3

Browse files
committed
Migrate Docker image publishing from Docker Hub to GitHub Container Registry
1 parent f6d4277 commit 202e4b3

1 file changed

Lines changed: 35 additions & 24 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@ env:
1212
IMAGE_NAME: graphql-engine
1313
#variables related with the repository
1414
REPOSITORY_MAIN_BRANCH: "master"
15-
#variables related with the docker imager registry
16-
DOCKER_IMAGE_REPOSITORY: mintproject
15+
#variables related with the docker image registry
16+
DOCKER_IMAGE_REPOSITORY: ghcr.io/mintproject
1717
DOCKER_IMAGE_NAME: graphql-engine
1818
DOCKER_FILE: "Dockerfile"
1919

2020
jobs:
2121
build:
2222
runs-on: ubuntu-latest
2323
if: github.event_name == 'push'
24+
permissions:
25+
contents: read
26+
packages: write
2427
steps:
2528
- name: Get branch name
2629
id: branch-name
2730
uses: tj-actions/branch-names@v6
2831

29-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v4
3033

3134
- name: Create environment variable with the commit id
3235
run: |
@@ -35,22 +38,23 @@ jobs:
3538
- name: Expose the commit id
3639
id: exposeValue
3740
run: |
38-
echo "::set-output name=docker_tag::${{ env.DOCKER_TAG }}"
41+
echo "docker_tag=${{ env.DOCKER_TAG }}" >> $GITHUB_OUTPUT
3942
4043
- name: Set up QEMU
41-
uses: docker/setup-qemu-action@v2
44+
uses: docker/setup-qemu-action@v3
4245

4346
- name: Set up Docker Buildx
44-
uses: docker/setup-buildx-action@v2
47+
uses: docker/setup-buildx-action@v3
4548

46-
- name: Login to DockerHub
47-
uses: docker/login-action@v1
49+
- name: Login to GitHub Container Registry
50+
uses: docker/login-action@v3
4851
with:
49-
username: ${{ secrets.DOCKERHUB_USERNAME }}
50-
password: ${{ secrets.DOCKERHUB_TOKEN }}
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
5155

5256
- name: Build and push Docker image
53-
uses: docker/build-push-action@v3.0.0
57+
uses: docker/build-push-action@v5
5458
with:
5559
push: true
5660
context: .
@@ -60,7 +64,7 @@ jobs:
6064

6165
- name: Running on the default branch.
6266
if: steps.branch-name.outputs.is_default == 'true'
63-
uses: docker/build-push-action@v3.0.0
67+
uses: docker/build-push-action@v5
6468
with:
6569
push: true
6670
context: .
@@ -72,11 +76,18 @@ jobs:
7276
permissions:
7377
contents: read
7478
security-events: write
75-
packages: write
79+
packages: read
7680
name: "Scan vulnerabilities in the image"
7781
needs: [build]
7882
runs-on: ubuntu-latest
7983
steps:
84+
- name: Login to GitHub Container Registry
85+
uses: docker/login-action@v3
86+
with:
87+
registry: ghcr.io
88+
username: ${{ github.actor }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
8091
- name: Run Trivy vulnerability scanner
8192
uses: aquasecurity/trivy-action@master
8293
with:
@@ -89,13 +100,13 @@ jobs:
89100
ignore-unfixed: "true"
90101

91102
- name: Upload Trivy scan results to GitHub Security tab
92-
uses: github/codeql-action/upload-sarif@v1
103+
uses: github/codeql-action/upload-sarif@v3
93104
if: always()
94105
with:
95106
sarif_file: "trivy-results.sarif"
96107

97108
update:
98-
needs: build
109+
needs: build
99110
runs-on: ubuntu-latest
100111
steps:
101112
- name: Create environment variable with the commit id
@@ -105,26 +116,26 @@ jobs:
105116
- name: Expose the commit id
106117
id: exposeValue
107118
run: |
108-
echo "::set-output name=docker_tag::${{ env.DOCKER_TAG }}"
119+
echo "docker_tag=${{ env.DOCKER_TAG }}" >> $GITHUB_OUTPUT
109120
110121
- name: Checkout MINT Instances Repository
111-
uses: actions/checkout@v3
122+
uses: actions/checkout@v4
112123
with:
113124
repository: mintproject/mint-instances
114125
path: infrastructure
115126
token: ${{ secrets.MINT_INSTANCES }}
116127
ref: master
117128

118129
- name: Checkout MINT Chart Repository
119-
uses: actions/checkout@v3
130+
uses: actions/checkout@v4
120131
if: github.ref == 'refs/heads/master'
121132
with:
122133
repository: mintproject/mint
123-
path: mint-chart
134+
path: mint-chart
124135
token: ${{ secrets.MINT_INSTANCES }}
125136
ref: main
126137

127-
- name: Update MINT ISI master
138+
- name: Update MINT ISI master
128139
uses: fjogeleit/yaml-update-action@main
129140
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
130141
with:
@@ -134,10 +145,10 @@ jobs:
134145
message: "Update hasura"
135146
repository: mintproject/mint-instances
136147
workDir: infrastructure
137-
branch: master
148+
branch: master
138149
token: ${{ secrets.MINT_INSTANCES }}
139150

140-
- name: Update MINT ISI WIFIRE
151+
- name: Update MINT ISI WIFIRE
141152
uses: fjogeleit/yaml-update-action@main
142153
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
143154
with:
@@ -147,7 +158,7 @@ jobs:
147158
message: "Update hasura"
148159
repository: mintproject/mint-instances
149160
workDir: infrastructure
150-
branch: master
161+
branch: master
151162
token: ${{ secrets.MINT_INSTANCES }}
152163

153164
- name: Update MINT ISI dev
@@ -160,7 +171,7 @@ jobs:
160171
message: "Update hasura"
161172
repository: mintproject/mint-instances
162173
workDir: infrastructure
163-
branch: master
174+
branch: master
164175
token: ${{ secrets.MINT_INSTANCES }}
165176

166177

0 commit comments

Comments
 (0)