Update #3235
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: Update | |
on: | |
schedule: | |
- cron: '36 3/6 * * *' | |
workflow_dispatch: | |
permissions: # added using https://github.com/step-security/secure-workflows | |
contents: read | |
jobs: | |
update: | |
permissions: | |
contents: write # for Git to git push | |
if: github.repository_owner == 'toolctl' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 | |
with: | |
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | |
- name: Add ~/.local/bin to the PATH | |
run: echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Install toolctl | |
run: curl -fsSL https://raw.githubusercontent.com/toolctl/install/main/install | sh | |
- name: Set the LocalAPIBasePath | |
env: | |
TOOLCTL_API_VERSION: v0 | |
run: | | |
config_dir="$HOME/.config/toolctl" | |
mkdir -p "${config_dir}" | |
echo LocalAPIBasePath: "${GITHUB_WORKSPACE}/${TOOLCTL_API_VERSION}" > "${config_dir}/config.yaml" | |
- name: Check out the repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
token: ${{secrets.TOOLCTL_BOT_TOKEN}} | |
fetch-depth: 0 | |
- name: Switch to the api-discover branch, regardless if it exists or not | |
run: | | |
git checkout origin/api-discover || | |
git checkout origin/main && git switch --create api-discover | |
- name: Sync the list of supported tools | |
run: toolctl api sync | |
- name: Discover updated versions for all tools | |
run: toolctl api discover | |
- name: Check if any files have changed | |
id: changed-files | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
# Set the GitHub Actions output | |
echo "any_changed=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push the changes | |
if: ${{steps.changed-files.outputs.any_changed == 'true'}} | |
run: | | |
git config user.name "toolctl bot" | |
git config user.email "toolctl.bot@gmail.com" | |
git add . | |
git commit -m "Update the toolctl API" | |
git push -u origin api-discover | |
- name: Create a pull request | |
if: ${{steps.changed-files.outputs.any_changed == 'true'}} | |
env: | |
GITHUB_TOKEN: ${{secrets.TOOLCTL_BOT_TOKEN}} | |
run: | | |
gh pr create \ | |
--title "Update the toolctl API" \ | |
--body "This PR updates the supported tools and discovered versions." | |
gh pr merge --auto --squash |