Update Upstream Commit Reference #223
This file contains hidden or 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 Upstream Commit Reference | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 2 * * *' # runs daily at 02:00 UTC | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-upstream-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo (default branch) | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set variables | |
| run: | | |
| echo "BRANCH=aerothemeplasma-upstream-commit" >> $GITHUB_ENV | |
| echo "FILE=upstream-commit.txt" >> $GITHUB_ENV | |
| - name: Prepare orphan branch | |
| run: | | |
| git fetch origin $BRANCH || true | |
| git checkout --orphan $BRANCH || git switch $BRANCH | |
| git reset --hard | |
| git clean -fdx | |
| - name: Fetch latest upstream commit info and save | |
| run: | | |
| git clone --depth=1 https://gitgud.io/wackyideas/aerothemeplasma.git upstream-repo | |
| cd upstream-repo | |
| SHA=$(git rev-parse HEAD) | |
| cd .. | |
| echo "$SHA" > $FILE | |
| cat $FILE | |
| - name: Commit and force-push | |
| run: | | |
| git add $FILE | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git commit -m "Update upstream commit info" || echo "Nothing to commit" | |
| git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
| git push origin $BRANCH --force |