ReleaseTrigger #11
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
name: ReleaseTrigger | |
on: | |
workflow_dispatch: | |
inputs: | |
execution: | |
description: 'Type of execution' | |
required: true | |
default: 'Manual' | |
type: choice | |
options: | |
- Manual | |
schedule: | |
# * is a special character in YAML, so we have to quote this string | |
- cron: '0 4 25 * *' | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: Release trigger action | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PUBLISH_KEY }} | |
- name: Check existing tag | |
id: check | |
run: | | |
echo "::set-output name=has_tag::$(git log --format='format:%d' --decorate-refs="refs/tags/v*" -n 1 | grep tag | wc -l)" | |
- name: Debug | |
run: | | |
echo "Has tag: ${{ steps.check.outputs.has_tag }}" | |
echo "---" | |
echo "Execution: ${{ github.event.inputs.execution }}" | |
echo "---" | |
echo "Should run: ${{ steps.check.outputs.has_tag == 0 || github.event.inputs.execution == 'Manual' }}" | |
- name: Update trigger | |
if: ${{ steps.check.outputs.has_tag == 0 || github.event.inputs.execution == 'Manual' }} | |
run: | | |
date +%s > .release-trigger | |
- name: Creat git branch | |
if: ${{ steps.check.outputs.has_tag == 0 || github.event.inputs.execution == 'Manual' }} | |
run: | | |
git config --global user.name 'Esta Nagy' | |
git config --global user.email '[email protected]' | |
git checkout -b release/run-${{ github.run_number }} | |
git add .release-trigger | |
git commit -asm "Triggering a release {patch}" | |
git push -f --set-upstream origin release/run-${{ github.run_number }} | |
- name: Create Pull Request | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: ${{ steps.check.outputs.has_tag == 0 || github.event.inputs.execution == 'Manual' }} | |
with: | |
github-token: ${{ secrets.PUBLISH_KEY }} | |
script: | | |
github.rest.pulls.create({ | |
owner: "${{ github.repository_owner }}", | |
repo: "file-barj", | |
head: "release/run-${{ github.run_number }}", | |
base: "main", | |
title: "Triggering a release {patch}" | |
}); |