Skip to content

Commit

Permalink
Merge pull request cupy#8366 from kmaehashi/fix-pr-actions
Browse files Browse the repository at this point in the history
Fix pull request project board workflows
  • Loading branch information
takagi authored and chainer-ci committed Feb 6, 2025
1 parent 146d466 commit 87d163e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 35 deletions.
42 changes: 8 additions & 34 deletions .github/workflows/pr-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,27 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Generate Token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
uses: actions/create-github-app-token@v1
id: token
with:
app_id: 349488
private_key: ${{ secrets.GH_APP_PROJECT_AUTOMATION_PEM }}
app-id: 349488
private-key: ${{ secrets.GH_APP_PROJECT_AUTOMATION_PEM }}

# Get the pull-request number.
- name: Download artifact
uses: actions/github-script@v6
uses: actions/download-artifact@v4
with:
script: |
const workflow_run_id = ${{ github.event.workflow_run.id }};
core.notice(`Triggered by: https://github.com/cupy/cupy/actions/runs/${workflow_run_id}`);
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: workflow_run_id,
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "PULL_REQUEST_NUMBER"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/PULL_REQUEST_NUMBER.zip', Buffer.from(download.data));
- run: unzip PULL_REQUEST_NUMBER.zip
name: PULL_REQUEST_NUMBER
github-token: ${{ steps.token.outputs.token }}
run-id: ${{ github.event.workflow_run.id }}

- name: Update Status
shell: /usr/bin/bash -uex "{0}"
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
run: |
PULL_REQUEST="$(cat 'PULL_REQUEST_NUMBER')"
echo "::notice::Pull-Request: #${PULL_REQUEST}"
echo "::notice::Pull-Request: #${PULL_REQUEST} (triggered by https://github.com/cupy/cupy/actions/runs/${{ github.event.workflow_run.id }})"
# https://github.com/orgs/cupy/projects/4
gh api graphql -F "pull_request=${PULL_REQUEST}" -f query='
Expand Down Expand Up @@ -114,11 +96,3 @@ jobs:
}
}
'
- name: Revoke Token
uses: actions/github-script@v6
if: always() && steps.token.outcome == 'success'
with:
github-token: ${{ steps.token.outputs.token }}
script: |
await github.rest.apps.revokeInstallationAccessToken();
2 changes: 1 addition & 1 deletion .github/workflows/pr-updated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
echo "The pull-request will be marked as Needs Attention from maintainers."
echo "${{ (github.event.pull_request || github.event.issue).number }}" > PULL_REQUEST_NUMBER
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: PULL_REQUEST_NUMBER
path: PULL_REQUEST_NUMBER

0 comments on commit 87d163e

Please sign in to comment.