cli: fitactivity fix remove-command flag #367
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: Run fitgen Triggered by Comment | |
on: | |
issue_comment: | |
types: | |
- created | |
permissions: {} | |
jobs: | |
run-fitgen: | |
if: ${{ github.event.issue.pull_request }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # allow push commit | |
steps: | |
- name: Check PR comment | |
id: check-comment | |
env: | |
COMMENT: ${{ github.event.comment.body }} # Sanitize input using env to prevent script injection attack | |
run: | | |
if [[ "$COMMENT" =~ ^run\ fitgen\ ([0-9]+\.[0-9]+)$ ]]; then | |
echo "trigger=true" >> $GITHUB_OUTPUT | |
echo "profile_version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT | |
else | |
echo "trigger=false" >> $GITHUB_OUTPUT | |
echo "Aborted: not a valid 'run fitgen <profile.version>' command" | |
exit 0 | |
fi | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
if: steps.check-comment.outputs.trigger == 'true' | |
with: | |
token: "${{ secrets.FIT }}" | |
- name: Checkout PR | |
if: steps.check-comment.outputs.trigger == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.FIT }} | |
run: | | |
gh pr checkout ${{ github.event.issue.number }} | |
- name: Set up Go | |
if: steps.check-comment.outputs.trigger == 'true' | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version: "stable" | |
- name: Run fitgen | |
if: steps.check-comment.outputs.trigger == 'true' | |
run: | | |
export wd=$(pwd) | |
echo $wd | |
cd internal/cmd/fitgen | |
go run main.go -f Profile.xlsx -p ../../../ -b all --profile-version ${{ steps.check-comment.outputs.profile_version }} --verbose -y | |
cd $wd | |
sed -E -i 's/profile\-v[0-9]+\.[0-9]+-lightblue.svg/\profile-v${{ steps.check-comment.outputs.profile_version }}-lightblue.svg/' README.md | |
cd cmd/fitconv | |
go generate | |
cd $wd | |
cd cmd/fitprint | |
go generate | |
cd $wd | |
- name: Commit and Push | |
if: steps.check-comment.outputs.trigger == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.FIT }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Hikmatulloh Hari Mukti" | |
git add . | |
git commit -m "gh actions: generate files for v${{ steps.check-comment.outputs.profile_version }}" | |
git push |