Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions .github/workflows/update-help-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,42 @@ jobs:
with:
app-id: ${{ vars.SEMGREP_DOCS_RELEASE_APP_ID }}
private-key: ${{ secrets.SEMGREP_DOCS_RELEASE_PRIVATE_KEY }}
# Fetch project source with GitHub Actions Checkout.
- uses: actions/checkout@v4

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Checkout new branch named based on latest tag

- name: Resolve latest Semgrep release tag
run: |
LATEST_VERSION=$(gh release view -R semgrep/semgrep --json tagName -q .tagName | sed 's/^v//g')
echo "LATEST_VERSION=$(gh release view -R semgrep/semgrep --json tagName -q .tagName | sed 's/^v//g')" >> $GITHUB_ENV
git checkout -b update_help_commands_$LATEST_VERSION
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}

- name: Run `semgrep --help` and update reference file with output
run: |
docker run --rm semgrep/semgrep:$LATEST_VERSION semgrep --help | sed -r 's/\x1B\[[0-9;]*[a-zA-Z]//g' | tee src/components/reference/_cli-help-output.md
sed -i '1i```' src/components/reference/_cli-help-output.md
echo '```' >> src/components/reference/_cli-help-output.md

- name: Run `semgrep scan --help` and update reference file with output
run: |
docker run --rm semgrep/semgrep:$LATEST_VERSION semgrep scan --help | sed -r 's/\x1B\[[0-9;]*[a-zA-Z]//g' | tee src/components/reference/_cli-help-scan-output.md
sed -i '1i```' src/components/reference/_cli-help-scan-output.md
echo '```' >> src/components/reference/_cli-help-scan-output.md

- name: Run `semgrep ci --help` and update reference file with output
run: |
docker run --rm semgrep/semgrep:$LATEST_VERSION semgrep ci --help | sed -r 's/\x1B\[[0-9;]*[a-zA-Z]//g' | tee src/components/reference/_cli-help-ci-output.md
sed -i '1i```' src/components/reference/_cli-help-ci-output.md
echo '```' >> src/components/reference/_cli-help-ci-output.md
- name: Commit changes, if any
run: |
if $(git diff --quiet); then
echo "No changes made, exiting."
else
echo "Committing changes."
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Updated help command output based on latest Semgrep release"
git push --set-upstream origin update_help_commands_$LATEST_VERSION
gh pr create --title "Update help command output for Semgrep $LATEST_VERSION" --body "This is an automatically generated PR"
fi
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}

- name: Create pull request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ steps.generate-token.outputs.token }}
branch: update_help_commands_${{ env.LATEST_VERSION }}
commit-message: Updated help command output based on latest Semgrep release
title: Update help command output for Semgrep ${{ env.LATEST_VERSION }}
body: This is an automatically generated PR
delete-branch: true
Loading