Approve Label Trigger #45
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
name: Approve Label Trigger | |
on: | |
issues: | |
types: | |
- labeled | |
jobs: | |
parseNewIssue: | |
if: contains(github.event.label.name, 'new model') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Comment on issue | |
- name: Comment on submission | |
id: submission-comment | |
uses: GrantBirki/[email protected] | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
file: .github/templates/new-model.md | |
# setup python | |
- name: setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: "pip" | |
- run: pip install -r requirements.txt | |
# generate report | |
- name: generate report | |
env: | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
COMMENT_ID: ${{ steps.submission-comment.outputs.comment-id }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
python3 .github/scripts/write_report.py | |
# steps if failure | |
- name: workflow url | |
if: failure() | |
id: workflow-url | |
run: | | |
echo "workflow_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT | |
- name: comment on failure | |
if: failure() | |
uses: GrantBirki/[email protected] | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
file: .github/templates/parse-workflow-fail.md | |
vars: | | |
workflow_url: ${{ steps.workflow-url.outputs.workflow_url }} | |
- name: add fail label | |
if: failure() | |
uses: actions-ecosystem/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
labels: workflow_error | |
requestReview: | |
if: contains(github.event.label.name, 'review requested') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: jenschelkopf/[email protected] | |
with: | |
recipients: review requested=@ModelAtlasofTheEarth/model_reviewers | |
message: 'A review of this submission has been requested from {recipients}' | |
createRepoAuthorization: | |
if: contains(github.event.label.name, 'approved') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# setup python | |
- name: setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: "pip" | |
- run: pip install -r requirements.txt | |
- name: Verify Labeler | |
id: verify_labeler | |
env: | |
GITHUB_TOKEN: ${{ secrets.TIM_PAT }} | |
USER: ${{ github.event.sender.login }} | |
OWNER: ${{ github.event.repository.owner.login }} | |
REPO: ${{ github.event.repository.name }} | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
run: | | |
AUTHORIZED=$(python3 .github/scripts/approval_authorization.py) | |
echo "authorized=${AUTHORIZED}" >> $GITHUB_OUTPUT | |
createNewRepo: | |
needs: createRepoAuthorization | |
if: ${{ needs.createRepoAuthorization.outputs.create_repo }} == "True" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# setup python | |
- name: setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: "pip" | |
- run: pip install -r requirements.txt | |
# create the model repo from the template | |
- name: create model repo | |
id: create-model-repo | |
env: | |
GITHUB_TOKEN: ${{ secrets.DAN_PAT }} | |
OWNER: ModelAtlasOfTheEarth | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
TEMPLATE: ModelAtlasOfTheEarth/mate_model_template | |
FLAGS: --public | |
run: | | |
REPO_NAME=$(python3 .github/scripts/generate_identifier.py) | |
gh repo create ${OWNER}/${REPO_NAME} --template $TEMPLATE $FLAGS | |
echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT | |
# parse metadata and write files to repo | |
- name: write metadata | |
env: | |
GITHUB_TOKEN: ${{ secrets.DAN_PAT }} | |
OWNER: ModelAtlasOfTheEarth | |
REPO: ${{ steps.create-model-repo.outputs.repo_name }} | |
ISSUE_NUMBER: ${{ github.event.issue.number }} | |
run: | | |
python3 .github/scripts/write_metadata.py | |
# steps if failure | |
- name: workflow url | |
if: failure() | |
id: workflow-url | |
run: | | |
echo "workflow_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT | |
- name: comment on failure | |
if: failure() | |
uses: GrantBirki/[email protected] | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
file: .github/templates/repo-workflow-fail.md | |
vars: | | |
repo_name: ${{ steps.create-model-repo.outputs.repo_name }} | |
workflow_url: ${{ steps.workflow-url.outputs.workflow_url }} | |
- name: add fail label | |
if: failure() | |
uses: actions-ecosystem/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
labels: workflow_error | |