Skip to content

Dispatch release

Dispatch release #8

name: Dispatch release
on:
workflow_dispatch:
inputs:
release-version:
description: Release version (vX.X)
required: true
type: string
branch-name:
description: Branch to release (prepare-release-X.X)
required: true
type: string
jobs:
dispatch-release:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout aggregator repository
uses: actions/checkout@v4
with:
submodules: false
ref: release-workflow
- uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # v1 v1.11.6
id: app-token
name: Generate app token
with:
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
private-key: ${{ secrets.VERSIONBUMP_GHAPP_PRIVATE_KEY }}
owner: gridsuite
- name: Get GitHub App User ID
id: get-user-id
run: |
echo $(gh api "/users/${RUNGHA_APP_SLUG}[bot]")
echo "user-id=$(gh api "/users/${RUNGHA_APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
- name: Setup git user
run: |
git config --global user.name "${RUNGHA_APP_SLUG}[bot]"
git config --global user.email "${RUNGHA_USER_ID}+${RUNGHA_APP_SLUG}[bot]@users.noreply.github.com"
env:
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
RUNGHA_USER_ID: ${{ steps.get-user-id.outputs.user-id }} # just for defense against script injection
- name: Load repo list from file or input
id: load_repos
run: |
if [[ -z "${{ github.event.inputs.repos_to_release }}" ]]; then
echo "ℹ️ No user input → load .github/config/repos-to-release.txt"
list="$(cat .github/config/repos-to-release.txt)"
else
echo "ℹ️ Input found → load user input"
list="${{ github.event.inputs.repos_to_release }}"
fi
echo "list<<EOF" >> $GITHUB_OUTPUT
echo "$list" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create tags and trigger release workflows
run: |
while read url; do
version=${{github.event.inputs.release-version}}
branch_name=${{github.event.inputs.branch-name}}
owner=$(echo "$url" | cut -d/ -f4)
repo=$(echo "$url" | cut -d/ -f5 | sed 's/\.git$//')
gh api repos/$owner/$repo/actions/workflows/release.yml/dispatches \
-f ref=main \
-f inputs[releaseVersion]="$version" \
-f inputs[gitReference]="$branch_name"
done <<< "${{ steps.load_repos.outputs.list }}"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}