Skip to content

Commit 70f4767

Browse files
committed
✏️ PR automation for metadata
1 parent 9b29724 commit 70f4767

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/python-publish.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v4
16+
with:
17+
persist-credentials: false # important to use PAT for pushing
1618

1719
- name: Set up Python
1820
uses: actions/setup-python@v4
@@ -39,17 +41,16 @@ jobs:
3941
mkdir -p metadata
4042
poetry run python -c "from ontolearner import OntoLearnerMetadataExporter; OntoLearnerMetadataExporter().export('metadata/ontolearner-metadata.rdf')"
4143
42-
# Commit metadata back to repo
44+
# Commit metadata back via a branch + PR
4345
- name: Commit and push metadata
4446
env:
4547
REPO_PUSH_TOKEN: ${{ secrets.REPO_PUSH_TOKEN }}
4648
run: |
4749
git config --global user.name "github-actions[bot]"
4850
git config --global user.email "[email protected]"
4951
50-
# Fetch and switch to main branch
51-
git fetch origin main
52-
git checkout main
52+
# Create/update temporary branch for metadata
53+
git checkout -B auto-update
5354
5455
# Add metadata files
5556
git add metadata/
@@ -58,11 +59,24 @@ jobs:
5859
if ! git diff --cached --quiet; then
5960
git commit -m ":bookmark: Update metadata after release"
6061
git remote set-url origin https://x-access-token:${REPO_PUSH_TOKEN}@github.com/sciknoworg/OntoLearner.git
61-
git push origin main
62+
git push origin auto-update --force
6263
else
6364
echo "No changes to commit"
6465
fi
6566
67+
# Create or update PR for metadata
68+
- name: Create or update Pull Request
69+
uses: peter-evans/create-pull-request@v5
70+
with:
71+
token: ${{ secrets.REPO_PUSH_TOKEN }}
72+
commit-message: ":bookmark: Update metadata after release"
73+
branch: auto-update
74+
base: main
75+
title: "🤖 Automated metadata update"
76+
body: "This PR updates Dublin Core metadata automatically after package release."
77+
labels: automated
78+
update-branch: true # ensures the PR is updated if it already exists
79+
6680
- name: Configure Poetry for PyPI
6781
run: |
6882
poetry config pypi-token.pypi ${{ secrets.TWINE_API_TOKEN }}

0 commit comments

Comments
 (0)