Skip to content

Update Upstream Commit Reference #223

Update Upstream Commit Reference

Update Upstream Commit Reference #223

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