chore(.github): use default runner tooling #3
Workflow file for this run
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: "auto-release" | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| jobs: | |
| trigger-release: | |
| if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') | |
| permissions: | |
| contents: write | |
| actions: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: verify PR was created by version-bump workflow | |
| uses: actions/github-script@v7 | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| PR_AUTHOR: ${{ github.event.pull_request.user.login }} | |
| with: | |
| script: | | |
| // Check if PR author is github-actions bot | |
| if (process.env.PR_AUTHOR !== 'github-actions[bot]') { | |
| core.setFailed(`Security check failed: PR was not created by github-actions bot (author: ${process.env.PR_AUTHOR})`) | |
| return | |
| } | |
| console.log('✅ All security checks passed') | |
| - name: get version and environment | |
| id: version | |
| uses: actions/github-script@v7 | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| with: | |
| script: | | |
| const { version } = require('./package.json') | |
| core.setOutput('version', version) | |
| // Extract environment from PR labels | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: process.env.PR_NUMBER | |
| }) | |
| const environmentLabel = pr.labels.find(label => label.name.startsWith('environment:')) | |
| const environment = environmentLabel ? environmentLabel.name.split(':')[1].trim() : 'production' | |
| core.setOutput('environment', environment) | |
| console.log(`Triggering release for version ${version} in ${environment} environment`) | |
| - name: trigger publish workflow | |
| uses: actions/github-script@v7 | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| ENVIRONMENT: ${{ steps.version.outputs.environment }} | |
| with: | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'publish.yml', | |
| ref: 'main', | |
| inputs: { | |
| environment: process.env.ENVIRONMENT | |
| } | |
| }) | |
| console.log(`Successfully triggered publish workflow for ${process.env.ENVIRONMENT} environment`) |