Skip to content

Commit

Permalink
NEW Create action
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jun 1, 2022
1 parent 74f5614 commit f08648e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Auto-tag
on:
push:
tags:
Expand All @@ -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
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -27,8 +27,4 @@ jobs:
steps:
- name: Auto-tag
uses: silverstripe/gha-auto-tag@main
with:
ref: ${{ github.ref }}
sha: ${{ github.sha }}

```
27 changes: 5 additions & 22 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
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
- name: Generate tag name
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-)
Expand All @@ -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

0 comments on commit f08648e

Please sign in to comment.