Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix fetch-depth and split workflows #1263

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Comment on PR

on:
workflow_run:
workflows: ["SHASUM summary"]
types:
- completed

jobs:
comment:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: download artifact
uses: actions/download-artifact@v4
with:
name: shasum-comment
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ github.event.workflow_run.id }}
- name: comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
let issue_number = Number(fs.readFileSync('./issue-number', 'utf8').trim());
let comment = fs.readFileSync('./comment', 'utf8').trim();

if (comment.length > 0) {
github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "${{ github.event.pull_request.head.sha }}\n\n" + comment
});
}
34 changes: 14 additions & 20 deletions .github/workflows/shasum-summary.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: comment a SHASUM summary for each changed release
name: SHASUM summary

on:
pull_request:
Expand All @@ -11,28 +11,22 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: show changed files
run: git diff --no-commit-id --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
run: |
git diff --no-commit-id --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
- name: run shasum-summary
run: python3 contrib/shasum-summary/main.py ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} > comment
- name: show comment
run: cat comment
- uses: actions/github-script@v7
- name: Store issue number
run: echo "${{ github.event.number }}" > issue-number
- name: Verify issue number file
run: cat issue-number
- uses: actions/upload-artifact@v4
with:
script: |
const fs = require('node:fs');
fs.readFile('comment', 'utf8', (err, comment) => {
if (err) {
console.error(err);
return;
}
if (comment.length > 0) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "${{ github.event.pull_request.head.sha }}\n\n" + comment
});
}
});
name: shasum-comment
path: |
comment
issue-number