enable docker on branch #936
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: Publish Docker image | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'origin' | |
tags: | |
- 'v*' | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v3 | |
- name: Extract Metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: tufin/oasdiff | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push main | |
id: docker_build_main | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
context: ./ | |
file: ./Dockerfile | |
tags: tufin/oasdiff:main, tufin/oasdiff:latest | |
labels: ${{ steps.meta.outputs.labels }} | |
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' | |
- name: Build and push tag | |
id: docker_build_tag | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
context: ./ | |
file: ./Dockerfile | |
tags: tufin/oasdiff:${{ github.ref_name }} | |
labels: ${{ steps.meta.outputs.labels }} | |
if: github.ref != 'refs/heads/main' && github.event_name != 'pull_request' | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |