Build and Push Docker Image #7
This file contains 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: Build and Push Docker Image | |
on: | |
workflow_dispatch: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set version | |
run: echo "CURRENT_VERSION=0.0.${{ github.run_number }}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ secrets.DOCKER_USERNAME }}/bw-vault-digest | |
tags: latest | |
labels: true | |
- name: Build and push multi-platform Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }},${{ secrets.DOCKER_USERNAME }}/bw-vault-digest:latest,${{ secrets.DOCKER_USERNAME }}/bw-vault-digest:${{ env.CURRENT_VERSION }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Create Git Tag | |
run: | | |
git tag v${{ env.CURRENT_VERSION }} | |
git push origin v${{ env.CURRENT_VERSION }} |