From f08648e83962489c6b176136ed678b88e5609d29 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 31 May 2022 16:02:20 +1200 Subject: [PATCH] NEW Create action --- .github/workflows/auto-tag.yml | 6 ++---- README.md | 6 +----- action.yml | 27 +++++---------------------- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index 9267c57..33446ca 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -1,3 +1,4 @@ +name: Auto-tag on: push: tags: @@ -8,7 +9,4 @@ jobs: runs-on: ubuntu-latest steps: - name: Auto-tag - uses: emteknetnz/gha-auto-tag@main - with: - ref: ${{ github.ref }} - sha: ${{ github.sha }} + uses: silverstripe/gha-auto-tag@main diff --git a/README.md b/README.md index fb04cd5..5fabfae 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Using the 'v' prefix to avoid confusion with the '2' branch naming convention th ## Usage -.github/workflows/auto-tag.yml +**.github/workflows/auto-tag.yml** ```yml on: push: @@ -27,8 +27,4 @@ jobs: steps: - name: Auto-tag uses: silverstripe/gha-auto-tag@main - with: - ref: ${{ github.ref }} - sha: ${{ github.sha }} - ``` diff --git a/action.yml b/action.yml index 0c7e68e..4482fdd 100644 --- a/action.yml +++ b/action.yml @@ -1,36 +1,20 @@ name: Auto-tag description: Automatically delete and re-release tags so that other github action modules can use something similar to carets e.g. v0.1 or v3 -inputs: - ref: - type: string - required: true - description: github.ref when workflow is triggered by x.y.z semver tag e.g. refs/tags/0.1.23 - sha: - type: string - required: true - description: SHA of the tag runs: using: composite steps: - - name: Validate inputs + - name: Validate ref shell: bash env: - REF: ${{ inputs.ref }} - SHA: ${{ inputs.sha }} + REF: ${{ github.ref }} run: | # refs/tags/0.1.23 => 0.1.23 TAG=$(echo $REF | cut -c 11-) if [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Valid tag $TAG" + echo "Valid semver tag $TAG" else - echo "Invalid tag $TAG" - exit 1 - fi - if [[ "$SHA" =~ ^[0-9a-f]{40}$ ]]; then - echo "Valid sha $SHA" - else - echo "Invalid sha $SHA" + echo "Invalid semver tag $TAG" exit 1 fi @@ -38,7 +22,7 @@ runs: id: generate_tag_name shell: bash env: - REF: ${{ inputs.ref }} + REF: ${{ github.ref }} run: | # refs/tags/0.1.23 => 0.1.23 TAG=$(echo $REF | cut -c 11-) @@ -56,7 +40,6 @@ runs: - name: Add tag to repo uses: silverstripe/gha-tag-release@main with: - sha: ${{ github.sha }} tag: ${{ steps.generate_tag_name.outputs.tag }} delete_existing: true release: false