-
Notifications
You must be signed in to change notification settings - Fork 2
44 lines (42 loc) · 1.69 KB
/
trigger-tag.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Trigger Dev Tag
on:
# Trigger on new commits to release branches
push:
branches: [ "release/**" ]
jobs:
trigger-tag:
runs-on: ubuntu-latest
steps:
# Checkout this repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Get branch name
- name: Set BRANCH_NAME to the current branch ${{ github.ref }}
run: |
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed 's/refs\/heads\///g')" >> $GITHUB_ENV
# Get next dev tag name on this branch
# First command lists all tags on the branch, filters to those containing '-dev', then grabs the last one
# Second command increments the final digit after dev, so 2022.1.1-dev1 will become 2022.1.1-dev2
# and 2022.1.1-dev9 will become 2022.1.1-dev10
- name: Get next dev tag name
run: |
LAST_TAG=$(git tag --sort=v:refname --merged ${{ env.BRANCH_NAME }} | grep -E '^[0-9]{4}\.[0-9]+\.[0-9]+-dev[0-9]+$' | tail -1)
echo "NEXT_TAG=$(echo $LAST_TAG | awk -F-dev -v OFS=-dev '{$NF += 1 ; print}')" >> $GITHUB_ENV
# Trigger the build
- name: Trigger the tagger workflow with branch ${{env.BRANCH_NAME}} and tag ${{ env.NEXT_TAG }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.ACAS_WORKFLOWS_TOKEN }}
script: |
github.rest.actions.createWorkflowDispatch({
owner: "mcneilco",
repo: "acas",
workflow_id: "tagger.yml",
ref: "${{env.BRANCH_NAME}}",
inputs: {
"branch-name": "${{env.BRANCH_NAME}}",
"tag-name": "${{env.NEXT_TAG}}"
}
});