github actions: only push if there is a git tag #4
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 | |
on: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "**" | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: login azurecr | |
uses: docker/login-action@v3 | |
with: | |
registry: histify.azurecr.io | |
username: github-actions | |
password: ${{ secrets.AZURECR_TOKEN }} | |
- name: setup buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: remote | |
endpoint: tcp://buildkitd.buildx:1234 | |
- name: prepare build metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: histify.azurecr.io/cypress | |
tags: | | |
type=ref,event=tag | |
- name: push | |
uses: docker/build-push-action@v5 | |
with: | |
push: ${{ github.ref == 'refs/heads/master' && startsWith(github.ref, 'refs/tags/') }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=histify.azurecr.io/cypress:cache | |
cache-to: type=registry,ref=histify.azurecr.io/cypress:cache | |
slack: | |
needs: [build] | |
if: "failure('build') && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))" | |
runs-on: self-hosted | |
steps: | |
- name: slack | |
uses: slackapi/[email protected] | |
with: | |
payload: '{"text": ":boom: ${{ github.repository }} <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|*build pipeline failed*> on `${{ github.ref_name }}`, by ${{ github.event.pusher.name }}; please fix :thanks:"}' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |