Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: implement tagging of repository on change #63

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/pull-request-semver-label-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Check PR for SemVer Label'
on:
pull_request:
types:
- labeled
- unlabeled
- opened
- reopened
- synchronize
branches:
- main

permissions:
pull-requests: read
contents: read

jobs:
semver-check:
name: 'Check PR for SemVer Label'
if: |
contains(github.event.pull_request.labels.*.name, 'skip-release') == false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Parse the SemVer label
id: label
uses: UKHomeOffice/match-label-action@v1
with:
labels: minor,major,patch
mode: singular

- name: Calculate SemVer value
id: calculate
uses: UKHomeOffice/semver-calculate-action@v2
with:
increment: ${{ steps.label.outputs.matchedLabels }}
github_token: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/pull-request-semver-tag-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'SemVer Tag on Main Merge'
on:
pull_request:
types:
- closed
branches:
- main

permissions:
pull-requests: read
contents: write

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
semver-tag:
name: 'Tag Repository with SemVer'
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'skip-release') == false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Parse the SemVer label
id: label
uses: UKHomeOffice/match-label-action@v1
with:
labels: minor,major,patch
mode: singular

- name: Calculate SemVer value
id: calculate
uses: UKHomeOffice/semver-calculate-action@v2
with:
increment: ${{ steps.label.outputs.matchedLabels }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PEM_FILE }}

- name: Tag Repository
uses: UKHomeOffice/semver-tag-action@v4
with:
tag: ${{ steps.calculate.outputs.version }}
github_token: ${{ steps.app-token.outputs.token }}