Automatically generate Code for API Updates and Release #2
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: 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" |