88 - ' **.md'
99 - ' .gitignore'
1010 - ' .github/workflows/pushrm.yml'
11+ workflow_dispatch :
1112 pull_request :
1213 paths-ignore :
1314 - ' **.md'
@@ -151,6 +152,9 @@ jobs:
151152 needs : [ test-script ]
152153 runs-on : ubuntu-22.04
153154 environment : docker.io
155+ permissions :
156+ contents : read
157+ packages : write
154158 steps :
155159 # Increase available disk space by removing unnecessary tool chains:
156160 # https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
@@ -165,27 +169,48 @@ jobs:
165169 - name : Set up Docker Buildx
166170 uses : docker/setup-buildx-action@v3
167171
172+ - name : Configure build revision
173+ id : vars
174+ run : echo "sha_short=${GITHUB_SHA:0:7}" >> "$GITHUB_OUTPUT"
175+
168176 - name : Login to Docker Hub
169- uses : docker/login-action@v2
177+ uses : docker/login-action@v3
178+ if : github.repository_owner == 'prodrigestivill'
170179 with :
171180 username : ${{ secrets.DOCKERHUB_USERNAME }}
172181 password : ${{ secrets.DOCKERHUB_TOKEN }}
173182
174- - name : Configure build revision
175- id : vars
176- run : echo "::set-output name=sha_short::${GITHUB_SHA:0:7}"
183+ - name : Login to GitHub Container Registry
184+ uses : docker/login-action@v3
185+ if : github.repository_owner != 'prodrigestivill'
186+ with :
187+ registry : ghcr.io
188+ username : ${{ github.actor }}
189+ password : ${{ secrets.GITHUB_TOKEN }}
177190
178- - name : Build images
179- env :
180- REGISTRY_PREFIX : ${{ secrets.DOCKERHUB_USERNAME }}/
181- BUILD_REVISION : ${{ steps.vars.outputs.sha_short }}
182- run : docker buildx bake --pull
191+ - name : Docker meta
192+ id : meta
193+ uses : docker/metadata-action@v5
194+
195+ - name : Get repo name
196+ run : |
197+ echo "REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2)" >> "$GITHUB_ENV"
198+ echo "GHCR_REPO=ghcr.io/$GITHUB_REPOSITORY_OWNER" >> "$GITHUB_ENV"
183199
184- - name : Push images
200+ - name : Build image
201+ uses : docker/bake-action@v6
185202 env :
186- REGISTRY_PREFIX : ${{ secrets.DOCKERHUB_USERNAME }}/
203+ REGISTRY_PREFIX : ${{ github.repository_owner == 'prodrigestivill' && secrets.DOCKERHUB_USERNAME || env.GHCR_REPO }}/
204+ IMAGE_NAME : ${{ github.repository_owner == 'prodrigestivill' && 'postgres-backup-local' || env.REPO_NAME }}
187205 BUILD_REVISION : ${{ steps.vars.outputs.sha_short }}
188- run : docker buildx bake --push
206+ with :
207+ push : true
208+ targets : alpine
209+ files : |
210+ ./docker-bake.hcl
211+ cwd://${{ steps.meta.outputs.bake-file-labels }}
212+ cwd://${{ steps.meta.outputs.bake-file-annotations }}
213+
189214
190215 # # Example of publish using GitHub Container Registry instead
191216 # publish:
0 commit comments