77
88env :
99 DOCKERHUB_IMAGE_NAME : shawndengdocker/ibkr_event_daemon
10- GITHUB_IMAGE_NAME : ShawnDen -coder/ibkr_event_daemon
10+ GITHUB_IMAGE_NAME : ghcr.io/shawnden -coder/ibkr_event_daemon
1111
1212jobs :
1313 push_to_registry :
14- name : Push Docker image to Docker Hub
14+ name : Push Docker image to Docker Hub and GHCR
1515 runs-on : ubuntu-latest
1616 steps :
1717 - name : Check out the repo
3737 uses : docker/login-action@v3
3838 with :
3939 registry : ghcr.io
40- username : ${{ github.repository_owner }}
40+ username : ${{ github.actor }}
4141 password : ${{ env.PERSONAL_ACCESS_TOKEN }}
4242
4343 - name : Set up QEMU
@@ -46,23 +46,24 @@ jobs:
4646 - name : Set up Docker Buildx
4747 uses : docker/setup-buildx-action@v3
4848
49- - name : Validate build configuration
50- uses : docker/build-push-action@v6
49+ - name : Docker meta
50+ id : meta
51+ uses : docker/metadata-action@v5
5152 with :
52- call : check
53+ images : |
54+ ${{ env.DOCKERHUB_IMAGE_NAME }}
55+ ${{ env.GITHUB_IMAGE_NAME }}
56+ tags : |
57+ type=raw,value=latest,enable={{is_default_branch}}
58+ type=ref,event=tag
59+ type=ref,event=pr
60+ type=sha,format=short
5361
54- - name : Build and push
62+ - name : Build and push Docker images
5563 uses : docker/build-push-action@v6
5664 with :
65+ context : .
5766 platforms : linux/amd64,linux/arm64
5867 push : true
59- tags : |
60- ${{env.DOCKERHUB_IMAGE_NAME}}:latest
61- ${{env.DOCKERHUB_IMAGE_NAME}}:${{ github.ref_name}}
62-
63- - name : Push image to GHCR
64- run : |
65- docker buildx imagetools create \
66- --tag ${{ env.GITHUB_IMAGE_NAME }}:latest \
67- --tag ${{ env.GITHUB_IMAGE_NAME }}:${{ github.ref_name }} \
68- ${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.ref_name }}
68+ tags : ${{ steps.meta.outputs.tags }}
69+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments