Skip to content

Commit

Permalink
add pr number
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwebgr committed May 6, 2024
1 parent 996fc67 commit eb08256
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 16 deletions.
57 changes: 41 additions & 16 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
run:
runs-on: ubuntu-latest
steps:
- name: 'Download artifact'
- name: 'Download coverage artifact'
uses: actions/github-script@v6
with:
script: |
Expand All @@ -29,23 +29,48 @@ jobs:
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverager.zip`, Buffer.from(download.data));
- name: 'Unzip artifact'
- name: 'Unzip coverager'
run: unzip coverager.zip

- name: 'Download PR number'
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 == "pr_number"
})[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}/pr_number.zip`, Buffer.from(download.data));
- name: 'Unzip pr_number'
run: unzip pr_number.zip

- name: Coveralls
uses: coverallsapp/github-action@v2

# - name: 'Comment on PR'
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# let fs = require('fs');
# let issue_number = Number(fs.readFileSync('./.resultset.json'));
# await github.rest.issues.createComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: issue_number,
# body: 'Thank you for the PR!'
# });
#
- name: 'Comment on PR'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let issue_number = Number(fs.readFileSync('./pr_number'));
let result_set = fs.readFileSync('./.last_run.json');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: `Thank you for the PR! ${result_set}`
});
11 changes: 11 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ jobs:
- name: Run tests
run: bundle exec rake

- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr/

- uses: actions/upload-artifact@v4
with:
name: coverager
Expand Down

0 comments on commit eb08256

Please sign in to comment.