-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create V3 of VoronDesign github workflows
- Loading branch information
Showing
8 changed files
with
130 additions
and
178 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
name: Post PR comment and assign labels | ||
on: | ||
workflow_call: | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout workflows repo ↪️ | ||
# Check out .github repo to gain access to scripts | ||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 | ||
with: | ||
repository: VoronDesign/.github | ||
persist-credentials: false | ||
- name: Setup python 3.11 🐍 | ||
id: python311 | ||
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 | ||
with: | ||
python-version: '3.11' | ||
- name: Install python packages 🛠️ | ||
# Install required packages | ||
id: pip-install-packages | ||
run: | | ||
pip install requests | ||
- name: Download artifact | ||
# Download the artifact that was stored during the PR CI process | ||
# This file contains the action_run_id and the pull_request number | ||
# which are often not accessible from contexts | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id }}, | ||
}); | ||
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "pr" | ||
})[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}}/pr.zip', Buffer.from(download.data)); | ||
- run: unzip pr.zip | ||
- name: Get action_run_id and pr_number | ||
# The PR file contains two files, one with the PR number and one with the action run ID | ||
# Store them in outputs so they're easily accessible to other steps in this workflow | ||
id: get_artifact_values | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
var fs = require('fs'); | ||
var pr_number = String(fs.readFileSync('${{github.workspace}}/pr_number')); | ||
var action_run_id = String(fs.readFileSync('${{github.workspace}}/action_run_id')); | ||
core.setOutput('pr_number', pr_number); | ||
core.setOutput('action_run_id', action_run_id); | ||
- name: Generate PR Comment 📃 | ||
id: generate_pr_comment | ||
# Generate the contents of the PR comment, this also stores the labels to be set on the PR | ||
# in the output variable "LABELS_TO_SET" | ||
run: | | ||
python3 ${{ github.workspace }}/scripts/generate_pr_comment.py --repository=${{ github.repository }} --action_id=${{ steps.get_artifact_values.outputs.action_run_id }} --out_file=${{ github.workspace }}/pr/pr-comment.md | ||
- name: Post/Update PR Comment 📣 | ||
# Actually post/update the comment in the PR | ||
uses: thollander/actions-comment-pull-request@8c77f42bbcc27c832a3a5962c8f9a60e34b594f3 | ||
with: | ||
filePath: ${{ github.workspace }}/pr/pr-comment.md | ||
pr_number: ${{ steps.get_artifact_values.outputs.pr_number }} | ||
comment_tag: voron_users_ci | ||
- name: Set labels on PR | ||
# The python script determined which labels should be set. By using PUT, this workflow will | ||
# also remove all labels that are not explicitly set by the python script. | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: |- | ||
curl --request PUT \ | ||
--header "Accept: application/vnd.github+json" \ | ||
--header "Authorization: Bearer $GH_TOKEN" \ | ||
--header "X-GitHub-Api-Version: 2022-11-28" \ | ||
--url https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.get_artifact_values.outputs.pr_number }}/labels \ | ||
-d '{"labels":[${{ steps.generate_pr_comment.outputs.LABELS_TO_SET}}]}' |
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
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
Oops, something went wrong.