Skip to content

Commit

Permalink
Provides PR information via artifact (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon committed Feb 25, 2024
1 parent 53e9fa6 commit bc6db3b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 37 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/pr-postbuild.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/pr-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PR Post Build
on:
workflow_run:
workflows: [PR Build]
types:
- completed
jobs:
postbuild:
name: Update PR
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Install Python modules
run: pip install PyGithub
- name: Update PR
run: |
from github import Auth, Github
import json
from urllib.request import urlopen
from zipfile import ZipFile
event = json.loads('''${{ toJSON(github.event.workflow_run) }}''')
gh = Github(auth=Auth.Token("${{ secrets.GITHUB_TOKEN }}"))
repo = gh.get_repo("${{ github.repository }}")
run = repo.get_workflow_run(event["id"])
info = None
for artifact in run.get_artifacts():
if artifact.name == "build-info":
info = artifact
with urlopen(info.archive_download_url) as info:
zip = ZipFile(info)
with zip.open("build-info.json") as info:
info = json.load(info)
cmp = repo.compare(info["base"], f"{info["author"]}:{info["head"]}")
if cmp.status != "behind":
pull = repo.get_pull(info["pr"])
ready = False
for label in pull.labels:
if label.name == "S-ready":
ready = True
if not ready:
pull.add_to_labels("S-ready")
shell: python
24 changes: 24 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,27 @@ jobs:
name: Build
uses: ./.github/workflows/ci-mac.yml
needs: prebuild
postbuild:
name: Post build
runs-on: ubuntu-latest
needs: [build-windows, build-linux, build-mac]
steps:
- name: Generate build information
run: |
import json
info = {
"pr": ${{ github.event.number }},
"base": "${{ github.base_ref }}",
"head": "${{ github.event.pull_request.head.sha }}",
"author": "${{ github.event.pull_request.head.user.login }}"
}
with open("build-info.json", "w") as fp:
json.dump(info, fp)
shell: python
- name: Upload build information
uses: actions/upload-artifact@v4
with:
name: build-info
path: build-info.json

0 comments on commit bc6db3b

Please sign in to comment.