From d30fdc9a258dbae1c9e6095d6f42dfe48bdca5b9 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 6 Apr 2024 05:26:21 -0700 Subject: [PATCH] feat: add cruft config and workflow --- .github/workflows/update-cruft-id.yml | 26 +++++++++++++++++++++ {{ cookiecutter.package_slug }}/.cruft.json | 16 +++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/update-cruft-id.yml create mode 100644 {{ cookiecutter.package_slug }}/.cruft.json diff --git a/.github/workflows/update-cruft-id.yml b/.github/workflows/update-cruft-id.yml new file mode 100644 index 0000000..92a2b14 --- /dev/null +++ b/.github/workflows/update-cruft-id.yml @@ -0,0 +1,26 @@ +name: Update Cruft Commit ID + +on: [push] + +jobs: + update-cruft: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Update .cruft.json with latest commit ID + run: | + CRUFT_FILE="./{{ cookiecutter.package_slug }}/.cruft.json" + LATEST_COMMIT_ID=$(git rev-parse HEAD) + echo "Latest commit ID: $LATEST_COMMIT_ID" + + jq --arg commit "$LATEST_COMMIT_ID" '.commit = $commit' "$CRUFT_FILE" > temp.json && mv temp.json "$CRUFT_FILE" + + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "GitHub Actions Bot" + git add "$CRUFT_FILE" + git commit -m "Automatically update .cruft.json with latest commit ID" + git push diff --git a/{{ cookiecutter.package_slug }}/.cruft.json b/{{ cookiecutter.package_slug }}/.cruft.json new file mode 100644 index 0000000..2478ed8 --- /dev/null +++ b/{{ cookiecutter.package_slug }}/.cruft.json @@ -0,0 +1,16 @@ +{ + "template": "https://github.com/danb27/python-package-template", + "commit": "foo", + "context": { + "cookiecutter": { + "package_name": "{{ cookiecutter.package_name }}", + "package_slug": "{{ cookiecutter.package_slug }}", + "package_title": "{{ cookiecutter.package_title }}", + "package_description": "{{ cookiecutter.package_description }}", + "author_name": "{{ cookiecutter.author_name }}", + "author_email": "{{ cookiecutter.author_email }}", + "line_length": {{ cookiecutter.line_length }} + } + }, + "skip": [] +} \ No newline at end of file