Dispatch release #11
This file contains hidden or 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: 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-vX.X) | |
required: true | |
type: string | |
pat-token: | |
description: PAT token (with workflow permissions) | |
required: true | |
type: string | |
jobs: | |
dispatch-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout aggregator repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: false | |
- name: Mask GH_TOKEN Token | |
run: | | |
GH_TOKEN=$(jq -r '.inputs.pat-token' $GITHUB_EVENT_PATH) | |
echo ::add-mask::$GH_TOKEN | |
echo "GH_TOKEN=$GH_TOKEN" >> $GITHUB_ENV | |
- name: Validate pat-token input | |
run: | | |
scopes=$(gh api -i user 2>&1 | grep -i 'x-oauth-scopes:' | cut -d' ' -f2-) | |
if [[ -n "$scopes" && "$scopes" == *"workflow"* ]]; then | |
echo "✅ Token is valid and has the 'workflow' scope" | |
elif [[ -n "$scopes" ]]; then | |
echo "⚠️ Token is valid but missing the 'workflow' scope" | |
exit 1 | |
else | |
echo "❌ Invalid token" | |
exit 1 | |
fi | |
env: | |
GH_TOKEN: ${{ env.GH_TOKEN }} | |
- 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: ${{ env.GH_TOKEN }} |