Skip to content

Commit efb70a1

Browse files
authored
feat: migrate docker hub push to github actions (#2016)
feat: migrate docker hub push to github actions
1 parent 25c852a commit efb70a1

3 files changed

Lines changed: 142 additions & 2 deletions

File tree

.github/workflows/mysql.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches:
88
- master
99
tags:
10-
- '**'
10+
- "**"
1111
workflow_dispatch: {}
1212

1313
env:
@@ -211,3 +211,50 @@ jobs:
211211
glob: "*.xml"
212212
parent: false
213213
process_gcloudignore: false
214+
215+
deploy-mysql-dockerhub:
216+
runs-on: ubuntu-latest
217+
needs: mysql-e2e-tests
218+
if: |
219+
github.ref == 'refs/heads/master' ||
220+
startsWith(github.ref, 'refs/tags/') ||
221+
startsWith(github.ref, 'refs/heads/feature.')
222+
223+
steps:
224+
- name: Download Docker image
225+
uses: actions/download-artifact@v6
226+
with:
227+
name: mysql-docker-image
228+
path: /tmp
229+
230+
- name: Load Docker image
231+
run: docker load --input /tmp/mysql-image.tar
232+
233+
- name: Log in to Docker Hub
234+
uses: docker/login-action@v3
235+
with:
236+
username: ${{ secrets.DOCKER_USER }}
237+
password: ${{ secrets.DOCKER_PASS }}
238+
239+
- name: Determine Docker tag
240+
id: docker-tag
241+
run: |
242+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
243+
DOCKER_TAG="${{ github.sha }}"
244+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
245+
DOCKER_TAG="${{ github.ref_name }}"
246+
elif [[ "${{ github.ref }}" == refs/heads/feature.* ]]; then
247+
DOCKER_TAG="${{ github.ref_name }}"
248+
else
249+
echo "Not pushing to DockerHub for ref=${{ github.ref }}"
250+
exit 0
251+
fi
252+
echo "tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
253+
echo "full_tag=${{ secrets.DOCKERHUB_REPO }}:${DOCKER_TAG}-mysql" >> $GITHUB_OUTPUT
254+
255+
- name: Tag and push Docker image
256+
if: steps.docker-tag.outputs.tag != ''
257+
run: |
258+
docker tag app:build ${{ steps.docker-tag.outputs.full_tag }}
259+
docker images
260+
docker push ${{ steps.docker-tag.outputs.full_tag }}

.github/workflows/postgres.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches:
88
- master
99
tags:
10-
- '**'
10+
- "**"
1111
workflow_dispatch: {}
1212

1313
env:
@@ -218,3 +218,49 @@ jobs:
218218
parent: false
219219
process_gcloudignore: false
220220

221+
deploy-postgres-dockerhub:
222+
runs-on: ubuntu-latest
223+
needs: postgres-e2e-tests
224+
if: |
225+
github.ref == 'refs/heads/master' ||
226+
startsWith(github.ref, 'refs/tags/') ||
227+
startsWith(github.ref, 'refs/heads/feature.')
228+
229+
steps:
230+
- name: Download Docker image
231+
uses: actions/download-artifact@v6
232+
with:
233+
name: postgres-docker-image
234+
path: /tmp
235+
236+
- name: Load Docker image
237+
run: docker load --input /tmp/postgres-image.tar
238+
239+
- name: Log in to Docker Hub
240+
uses: docker/login-action@v3
241+
with:
242+
username: ${{ secrets.DOCKER_USER }}
243+
password: ${{ secrets.DOCKER_PASS }}
244+
245+
- name: Determine Docker tag
246+
id: docker-tag
247+
run: |
248+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
249+
DOCKER_TAG="${{ github.sha }}"
250+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
251+
DOCKER_TAG="${{ github.ref_name }}"
252+
elif [[ "${{ github.ref }}" == refs/heads/feature.* ]]; then
253+
DOCKER_TAG="${{ github.ref_name }}"
254+
else
255+
echo "Not pushing to DockerHub for ref=${{ github.ref }}"
256+
exit 0
257+
fi
258+
echo "tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
259+
echo "full_tag=${{ secrets.DOCKERHUB_REPO }}:${DOCKER_TAG}-postgres" >> $GITHUB_OUTPUT
260+
261+
- name: Tag and push Docker image
262+
if: steps.docker-tag.outputs.tag != ''
263+
run: |
264+
docker tag app:build ${{ steps.docker-tag.outputs.full_tag }}
265+
docker images
266+
docker push ${{ steps.docker-tag.outputs.full_tag }}

.github/workflows/spanner.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,50 @@ jobs:
224224
glob: "*.xml"
225225
parent: false
226226
process_gcloudignore: false
227+
228+
deploy-spanner-dockerhub:
229+
runs-on: ubuntu-latest
230+
needs: spanner-e2e-tests
231+
if: |
232+
github.ref == 'refs/heads/master' ||
233+
startsWith(github.ref, 'refs/tags/') ||
234+
startsWith(github.ref, 'refs/heads/feature.')
235+
236+
steps:
237+
- name: Download Docker image
238+
uses: actions/download-artifact@v6
239+
with:
240+
name: spanner-docker-image
241+
path: /tmp
242+
243+
- name: Load Docker image
244+
run: docker load --input /tmp/spanner-image.tar
245+
246+
- name: Log in to Docker Hub
247+
uses: docker/login-action@v3
248+
with:
249+
username: ${{ secrets.DOCKER_USER }}
250+
password: ${{ secrets.DOCKER_PASS }}
251+
252+
- name: Determine Docker tag
253+
id: docker-tag
254+
run: |
255+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
256+
DOCKER_TAG="${{ github.sha }}"
257+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
258+
DOCKER_TAG="${{ github.ref_name }}"
259+
elif [[ "${{ github.ref }}" == refs/heads/feature.* ]]; then
260+
DOCKER_TAG="${{ github.ref_name }}"
261+
else
262+
echo "Not pushing to DockerHub for ref=${{ github.ref }}"
263+
exit 0
264+
fi
265+
echo "tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
266+
echo "full_tag=${{ secrets.DOCKERHUB_REPO }}:${DOCKER_TAG}-spanner" >> $GITHUB_OUTPUT
267+
268+
- name: Tag and push Docker image
269+
if: steps.docker-tag.outputs.tag != ''
270+
run: |
271+
docker tag app:build ${{ steps.docker-tag.outputs.full_tag }}
272+
docker images
273+
docker push ${{ steps.docker-tag.outputs.full_tag }}

0 commit comments

Comments
 (0)