Skip to content

Approve Label Trigger #21

Approve Label Trigger

Approve Label Trigger #21

Workflow file for this run

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
# 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 }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 .github/scripts/write_report.py
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: Verify Labeler
id: verify_labeler
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.event.repository.owner.login }}
REPO: ${{ github.event.repository.name }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
echo "create_repo=true" >> $GITHUB_OUTPUT
ALLOWED_USERS="hvidy"
IFS=',' read -ra ALLOWED_USERS_ARRAY <<< "$ALLOWED_USERS"
USER_ALLOWED=false
for ALLOWED_USER in "${ALLOWED_USERS_ARRAY[@]}"; do
if [ "$ALLOWED_USER" == "${{ github.event.sender.login }}" ]; then
USER_ALLOWED=true
break
fi
done
if [ "$USER_ALLOWED" == false ]; then
echo "Error: User not allowed to add approved label."
gh api --method DELETE /repos/${OWNER}/${REPO}/issues/${ISSUE_NUMBER}/labels/approved
echo "create_repo=false" >> $GITHUB_OUTPUT
fi
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