[MWPW-147001] Stage initiative automation (Stage-Main sync PRs) #1
This file contains 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: Merge to stage | |
on: | |
schedule: | |
- cron: '0 8 * * *' # Run once a day at 8:00 UTC. For any cases where adding the label wouldnt work | |
workflow_dispatch: # Allow manual trigger | |
pull_request: | |
types: [labeled] # Run when a label is added to a PR | |
env: | |
MILO_RELEASE_SLACK_WH: ${{ secrets.MILO_RELEASE_SLACK_WH }} | |
REQUIRED_APPROVALS: ${{ secrets.REQUIRED_APPROVALS }} | |
jobs: | |
merge-to-stage: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4.1.1 | |
- name: Check label | |
id: check_label | |
uses: actions/github-script@v7.0.1 | |
with: | |
script: | | |
const fs = require('fs'); | |
const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')); | |
if (process.env.GITHUB_EVENT_NAME === 'pull_request') { | |
const { label: { name } } = event; | |
if (name !== 'Ready for Stage') { | |
console.log('Label is not "Ready for Stage", stopping workflow...'); | |
return false; | |
} | |
} | |
return true; | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Merge to stage or queue to merge | |
if: steps.check_label.outputs.result == 'true' | |
uses: actions/github-script@v7.0.1 | |
with: | |
script: | | |
const main = require('./.github/workflows/merge-to-stage.js') | |
main({ github, context, core }) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |