Skip to content

Added not operator to failedOperations filter #165

Added not operator to failedOperations filter

Added not operator to failedOperations filter #165

# automatically publishes v tags to dockerhub.
# so for instance v0.5.1 wil publish but randtom wont
name: Build and Publish Version Tags
on:
push:
branches:
- '**'
tags:
- "v*"
jobs:
# define job to build and publish docker image
build-and-push-docker-image:
name: Build Docker image and push to repositories
# run only when code is compiling and tests are passing
runs-on: ubuntu-latest
env:
IMAGE: ${{ secrets.DOCKER_IMAGE || 'openstad/api' }}
# steps to perform in job
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE }}
tags: |
# branch event
type=ref,event=branch,suffix=-{{sha}}
# tag event
type=ref,event=tag
# setup Docker buld action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image and push to Docker Hub and GitHub Container Registry
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
# Comment build info in commit
- uses: actions/[email protected]
env:
STDOUT: "Published new image: `${{ fromJson(steps.docker_build.outputs.metadata)['image.name'] }}`"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
body: process.env.STDOUT
})
- name: Image digest
run: echo "${{ steps.docker_build.outputs.metadata }}"