-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(action-git): add advance-tag action
- Loading branch information
1 parent
3b875a4
commit d42f43e
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Git: advance-tag | ||
|
||
## Behavior | ||
|
||
Move a named tag to current commit. Recreates the tag if it's absent. | ||
|
||
## Usage | ||
|
||
```yaml | ||
jobs: | ||
advanceTag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout Code" | ||
uses: "actions/checkout@v2" | ||
|
||
- name: "Move tag" | ||
uses: "meero-com/github-actions-shared-workflows/actions/git/advance-tag@main" | ||
with: | ||
TAG_NAME: "DEV" | ||
github-token: ${{ secrets.API_TOKEN_GITHUB }} | ||
``` | ||
Beware of using a `@ref` (`@main` in the example above) which suits your stability requirements in your workflow: | ||
|
||
* Use `@main` if you always want to use the latest version of the workflow. | ||
* Use `@<tag>` if you wan to use a specific frozen version of the workflow. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: "Advance or create tag" | ||
description: "Advance or create tag" | ||
|
||
inputs: | ||
TAG_NAME: | ||
description: "Name of the tag" | ||
required: true | ||
github-token: | ||
description: The GitHub token used to create an authenticated client | ||
default: ${{ github.token }} | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Advance nightly tag | ||
uses: actions/github-script@v3 | ||
with: | ||
github-token: ${{ inputs.github-token }} | ||
script: | | ||
try { | ||
await github.git.deleteRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: "tags/${{ inputs.TAG_NAME }}" | ||
}) | ||
} catch (e) { | ||
console.log("The ${{ inputs.TAG_NAME }} tag doesn't exist yet: " + e) | ||
} | ||
await github.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: "refs/tags/${{ inputs.TAG_NAME }}", | ||
sha: context.sha | ||
}) |