new_release #96
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 of this GitHub Actions workflow. | |
name: Update semgrep help command | |
on: | |
repository_dispatch: | |
types: [new_release] | |
workflow_dispatch: {} | |
jobs: | |
update-output: | |
name: Update `--help` and `--help scan` command output | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
# Fetch project source with GitHub Actions Checkout. | |
- uses: actions/checkout@v4 | |
- name: Checkout new branch named based on latest 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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run `semgrep --help` and update reference file with output | |
run: | | |
docker run --rm semgrep/semgrep:$LATEST_VERSION semgrep --help | 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 | 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 | 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 [email protected] | |
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: ${{ secrets.GITHUB_TOKEN }} |