-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(github-actions): ensure single tag for automated commits and upd…
…ate PR creation action Added a GitHub Action to check for a single tag on the last commit in a PR to enforce workflow consistency and prevent tagging errors. Updated the `create-pull-request` action to the latest version, added explicit author and committer fields, and specified a reviewer to streamline the automated model update process. Removed the pre-merge checklist from the pull request body to simplify and focus on automated tasks.
- Loading branch information
Showing
2 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Check Tag on Automated Commit | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
check-tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get PR Author | ||
id: pr_author | ||
run: | | ||
pr_author_email=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" \ | ||
| jq -r .user.email) | ||
echo "author_email=$pr_author_email" >> $GITHUB_ENV | ||
- name: Check for Single Tag on Last Commit | ||
if: env.author_email == '[email protected]' | ||
run: | | ||
last_commit=$(git rev-parse HEAD) | ||
tags=$(git tag --contains $last_commit) | ||
tag_count=$(echo "$tags" | wc -l | xargs) | ||
if [ "$tag_count" -ne 1 ]; then | ||
echo "The last commit does not have exactly one tag." | ||
exit 1 | ||
fi | ||
echo "Commit $last_commit has exactly one tag: $tags" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,10 @@ jobs: | |
generate-and-create-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
|
@@ -28,17 +28,17 @@ jobs: | |
- name: Extract Version from Cargo.toml | ||
run: | | ||
version=$(python -c "import toml; print(toml.load('Cargo.toml')['package']['version'])") | ||
echo "Extracted version: $version" | ||
echo "VERSION=$version" >> $GITHUB_ENV | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
title: "Automated Model Update" | ||
commit-message: "Automated update of model definitions" | ||
branch: "update-models-${{ steps.extract_version.outputs.version }}" | ||
branch: "update-models-${{ env.VERSION }}" | ||
author: "GitHub Workflow <[email protected]>" | ||
committer: "GitHub Workflow <[email protected]>" | ||
reviewers: "Sett17" | ||
body: | | ||
This is an automated pull request to update the model definitions. | ||
**Before merging:** | ||
- [ ] Ensure to create a new tag with the version ${{ steps.extract_version.outputs.version }} after merging. | ||
signoff: true |