Skip to content

release(1.2.2): patch #15

release(1.2.2): patch

release(1.2.2): patch #15

Workflow file for this run

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@v5
with:
ref: main
- name: verify PR was created by version-bump workflow
uses: actions/github-script@v8
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@v8
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
with:
script: |
// 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 releaseTypeLabel = pr.labels.find(label => label.name.startsWith('release_type:'))
const releaseType = releaseTypeLabel ? releaseTypeLabel.name.split(':')[1].trim() : 'patch'
core.setOutput('release_type', releaseType)
console.log(`Triggering ${releaseType} release in production environment`)
- name: trigger publish workflow
uses: actions/github-script@v8
env:
RELEASE_TYPE: ${{ steps.version.outputs.release_type }}
REF: ${{ github.event.pull_request.head.ref }}
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'publish.yml',
ref: process.env.REF,
inputs: {
environment: 'production',
release_type: process.env.RELEASE_TYPE
}
})
console.log(`Successfully triggered publish workflow for production environment`)