Skip to content

Commit

Permalink
Trigger the workflows only on push, allow auto-release on tag (#16)
Browse files Browse the repository at this point in the history
The 'push' and 'pull_request' triggers together are redundant in a PR, and
cause the PR to get two builds.

The 'push' trigger is firing in a PR and on merge to master, so it should
be sufficient.

Make the auto-release via tag depend on a successful build.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe authored Mar 19, 2024
1 parent 22613e5 commit 1ab1885
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 37 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Docker build and push

on:
push:
branches:
- '*'
tags:
- 'v*'
on: [push]

env:
# TEST_TARGET: Name of the testing target in the Dockerfile
Expand All @@ -14,9 +9,6 @@ env:
# DO_TEST - true to build and run unit tests, false to skip the tests
DO_TEST: true

# DO_PUSH - true to push to the HPE_DEPLOY_REPO, false to not push
DO_PUSH: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -98,3 +90,23 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}

create_release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Repair tag
run: git fetch -f origin ${{ github.ref }}:${{ github.ref }}
- name: Verify that the tag is annotated
run: if test x$(git for-each-ref ${{ github.ref }} | awk '{print $2}') = xtag; then /bin/true; else echo "\"${{ github.ref }}\" does not look like an annotated tag!"; /bin/false; fi
- name: Release
uses: softprops/action-gh-release@v1
with:
#prerelease: true
generate_release_notes: true

28 changes: 0 additions & 28 deletions .github/workflows/verify_tag.yml

This file was deleted.

0 comments on commit 1ab1885

Please sign in to comment.