diff --git a/.github/workflows/tag_check.yml b/.github/workflows/tag_check.yml new file mode 100644 index 0000000..3a5b1ee --- /dev/null +++ b/.github/workflows/tag_check.yml @@ -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 == 'noreply@github.com' + 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" diff --git a/.github/workflows/update_models.yml b/.github/workflows/update_models.yml index aae8735..b293922 100644 --- a/.github/workflows/update_models.yml +++ b/.github/workflows/update_models.yml @@ -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 " + committer: "GitHub Workflow " + 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