Docker Image Build and Push #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Image Build and Push | |
| on: | |
| # push: | |
| # branches: [ "master" ] | |
| # pull_request: | |
| # branches: [ "master" ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Get date | |
| id: date | |
| run: echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| sbom: true | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.date.outputs.date }} | |
| - name: Push the Docker image with latest tag | |
| run: docker tag ${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{ steps.date.outputs.date }} ${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest && docker push ${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest |