Build Metadata and Create PR #3
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: Build Metadata and Create PR | |
on: | |
workflow_dispatch: # Allows the workflow to be triggered manually | |
jobs: | |
run-script-and-create-pr: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
# Step 3: Install dependencies (if any) | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
# Step 4: Run the Python script | |
- name: Run metadata generator script | |
run: | | |
python scripts/metadata-generator.py | |
# Step 5: Checkout the second repository to create the PR | |
- name: Checkout target repository | |
uses: actions/checkout@v3 | |
with: | |
repository: Chrystinne/pr-metadata-generator | |
path: pr-repo | |
token: ${{ secrets.MY_PERSONAL_TOKEN }} | |
# Step 6: Copy the datasets folder to the target repo | |
- name: Copy datasets to target repo | |
run: | | |
cp -r datasets pr-repo/ | |
# Step 7: Create a new branch in the target repo | |
- name: Create new branch | |
run: | | |
cd pr-repo | |
git checkout -b metadata-update-branch | |
# Step 8: Set up Git user | |
- name: Set up Git user | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "chrystinne" | |
# Step 9: Commit changes | |
- name: Commit changes | |
run: | | |
cd pr-repo | |
git add datasets | |
git commit -m "Add datasets from metadata generator" | |
# Step 10: Push the new branch | |
- name: Push changes | |
run: | | |
cd pr-repo | |
git push origin metadata-update-branch | |
# Step 11: Create a pull request | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.MY_PERSONAL_TOKEN }} | |
commit-message: "Add datasets from metadata generator" | |
branch: metadata-update-branch | |
base: main | |
title: "Metadata update from Python script" | |
body: "This PR contains the datasets folder generated by the metadata-generator script." |