Skip to content

Verify diff for 'Needs autoupgrade PR' label #93

Verify diff for 'Needs autoupgrade PR' label

Verify diff for 'Needs autoupgrade PR' label #93

# This workflow allows you to check potential changes to the structure of the database,
# and to apply the “Needs autoupgrade PR” label if this is the case
name: Verify diff for 'Needs autoupgrade PR' label
on:
workflow_run:
workflows: [ Create diff for 'Needs autoupgrade PR' label ]
types:
- completed
jobs:
update_label:
name: Update Needs autoupgrade PR label
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "sql_diff"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/sql_diff.zip`, Buffer.from(download.data));
- name: Unzip artifact
run: unzip sql_diff.zip
- name: Check diff for label
run: |
NUMBER=$(cat ./pr_number)
if [ -s sql-diff.txt ]; then
gh pr edit "$NUMBER" --add-label "$LABELS"
else
gh pr edit "$NUMBER" --remove-label "$LABELS"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
LABELS: Needs autoupgrade PR