Skip to content

feat(deps): Add devbox config #7

feat(deps): Add devbox config

feat(deps): Add devbox config #7

Workflow file for this run

name: "ASDF to Devbox dependency version sync"
# This is only required until https://github.com/renovatebot/renovate/issues/27543 is resolved
on:
pull_request:
paths:
- ".tool-versions"
jobs:
asdf2devbox:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
# We potentially want to add at the end a commit by the author of the most recent
# commit in this branch. However github has some protection which prevents workflows
# to run in case a commit has been pushed with the default job-specific github-token.
# For this case we need to use another one here.
#
# For more information, see:
# <https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow>
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.APP_AUTOSCALER_CI_TOKEN }} # With push token that can trigger new PR jobs
- name: Configure git
id: configure_git
shell: bash
run: |
#! /usr/bin/env bash
set -eu -o pipefail
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
commit_author_name="$(git log -1 --pretty=format:'%an')"
commit_author_email="$(git log -1 --pretty=format:'%ae')"
commit_subject="$(git log -1 --pretty=format:'%s')"
readonly commit_author_name commit_author_email commit_subject
git config user.name "${commit_author_name}"
git config user.email "${commit_author_email}"
echo "commit_subject=${commit_subject}" >> "$GITHUB_OUTPUT"
- name: Install devbox
uses: jetify-com/[email protected]
with:
enable-cache: 'true'
- name: asdf2devbox.py
shell: bash
run: |
#! /usr/bin/env bash
set -eu -o pipefail
# We need the subsequent standard-message to determine if the last commit
# has already cleaned up everything. In this case this workflow should not
# change anything and we exit early.
# An alternative would be to use a tag for this. But this does affect the whole
# PR instead of just the latest commit.
tidy_message='🤖🦾🛠️ scripts/asdf2devbox.py'
readonly tidy_message
commit_message='${{steps.configure_git.outputs.commit_subject}}'
readonly commit_message
if [[ "${commit_message}" == "${tidy_message}" ]]
then
echo 'This commit was by the asdf2devbox workflow! Exiting …'
exit 0
fi
devbox run scripts/asdf2devbox.py
num_changed_files="$(git status --porcelain | wc --lines)"
declare -i -r num_changed_files
if ((num_changed_files > 0))
then
echo 'Changes to some files were necessary!'
git add .
git commit --message="${tidy_message}"
git push
else
echo 'No files changed!'
fi
echo '🏁'