Skip to content

add GITHUB_TOKEN

add GITHUB_TOKEN #11

Workflow file for this run

name: Test
on:
push:
branches:
- main
- 'release/v*'
jobs:
release-tag:
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.head_commit.message, 'release:') }}
steps:
# Since skip-github-release is specified, the outputs of googleapis/release-please-action cannot be used.
# Therefore, we need to parse the version ourselves.
- name: Extract version and PR number from commit message
id: extract_info
shell: bash
run: |
echo "version=$( echo "${{ github.event.head_commit.message }}" | sed 's/^release: v\([0-9]\+\.[0-9]\+\.[0-9]\+\).*$/\1/' )" >> $GITHUB_OUTPUT
echo "pr_number=$( echo "${{ github.event.head_commit.message }}" | sed 's/.*(\#\([0-9]\+\)).*$/\1/' )" >> $GITHUB_OUTPUT
echo "release_branch=release/v($ echo "${{ github.event.head_commit.message }}" | sed 's/^release: v\([0-9]\+\.[0-9]\+\).*$/\1/' )" >> $GITHUB_OUTPUT
# When v0.50.0 is released, a release branch "release/v0.50" is created.
- name: Add release branch to rulesets
if: ${{ endsWith(steps.extract_info.outputs.version, '.0') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
RULESET_ID=$(gh api /repos/"${{ github.repository }}"/rulesets --jq '.[] | select(.name == "release") | .id')
gh api /repos/"${{ github.repository }}"/rulesets/"$RULESET_ID" | jq '{conditions}' | jq '.conditions.ref_name.include += [echo "${{ github.event.head_commit.message }}"]' | gh api --method put --input - /repos/aquasecurity/trivy-backport-test/rulesets/877307