Skip to content

Commit

Permalink
added Tagging workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsef committed Oct 24, 2021
1 parent 2c88a56 commit 6d8fc09
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/tagging.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
name: Tagging
on:
push:
branches:
- master
workflow_run:
workflows:
- CI
types:
- completed
branch:
- main
paths:
- "deployment/*"
workflow_dispatch:

env:
COMMIT_MSG: ${{ github.event.head_commit.message }}

jobs:
tagging:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'master') }}
if: ${{ contains(github.ref, 'main') }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Fetch remote tags
run: git fetch origin +refs/tags/*:refs/tags/*
- name: Set Tag Value
run: |
echo "DATE=v$(echo `date +'%Y.%m'`)" >> $GITHUB_ENV
echo "CHANGELOG=`git log --oneline $(git describe --tags v2021.08 --abbrev=0 @^ | head -n 1)..@`" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v4
if: ${{ env.DATE }}
Expand All @@ -32,19 +39,20 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.DATE }}",
message: "${{ env.CHANGELOG }}",
sha: context.sha
});
} catch (e) { // Tag alredy exists
if (e.status == 422) {
tagExists.push(e);
}
} catch (e) {
console.log("Tag already exists: " + e)
tagExists.push(e);
}
if (tagExists.length > 0) {
await github.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ env.DATE }}",
message: "${{ env.CHANGELOG }}",
sha: context.sha
});
}
}

0 comments on commit 6d8fc09

Please sign in to comment.