.github/workflows/on_pr_merge.yml #65
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
# Maintenance: Verify why we're having permissions issues even with write scope, then re-enable it. | |
# logs: https://github.com/awslabs/aws-lambda-powertools-python/runs/7030238348?check_suite_focus=true | |
on: | |
workflow_run: | |
workflows: ["Record PR details"] | |
types: | |
- completed | |
env: | |
RELEASE_LABEL: "pending-release" | |
MAINTAINERS_TEAM: "@awslabs/aws-lambda-powertools-python" | |
jobs: | |
release_label_on_merge: | |
if: > | |
${{ github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' }} | |
# if: github.event.pull_request.merged == true && github.event.pull_request.user.login != 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: "Download artifact" | |
uses: actions/github-script@v6 | |
# For security, we only download artifacts tied to the successful PR recording workflow | |
with: | |
script: | | |
const fs = require('fs'); | |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id }}, | |
}); | |
const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0]; | |
const artifact = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(artifact.data)); | |
# NodeJS standard library doesn't provide ZIP capabilities; use system `unzip` command instead | |
- run: unzip pr.zip | |
- name: "Label PR related issue for release" | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const script = require('.github/scripts/label_related_issue.js') | |
await script({github, context, core}) |