Skip to content

Commit

Permalink
feat(action-git): add advance-tag action
Browse files Browse the repository at this point in the history
  • Loading branch information
JoffreyPlouvier committed Feb 21, 2023
1 parent 3b875a4 commit d42f43e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
27 changes: 27 additions & 0 deletions actions/git/advance-tag/README.md
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.
35 changes: 35 additions & 0 deletions actions/git/advance-tag/action.yml
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
})

0 comments on commit d42f43e

Please sign in to comment.