Sync GStack to CodeBuddy #15
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: Sync GStack to CodeBuddy | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "GStack Bot" | |
| git config --global user.email "bot@github.com" | |
| - name: Check for GStack updates | |
| id: check | |
| run: | | |
| git remote add gstack https://github.com/garrytan/gstack.git 2>/dev/null || true | |
| git fetch gstack main --depth 1 2>/dev/null || git fetch gstack master --depth 1 2>/dev/null || true | |
| LOCAL=$(git rev-parse HEAD) | |
| REMOTE=$(git rev-parse gstack/main 2>/dev/null || git rev-parse gstack/master 2>/dev/null || echo "$LOCAL") | |
| if [ "$LOCAL" != "$REMOTE" ]; then | |
| echo "updates=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "updates=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and tag | |
| if: steps.check.outputs.updates == 'true' | |
| run: | | |
| DATE=$(date +%Y%m%d) | |
| git add -A | |
| git commit -m "Sync with GStack $(date '+%Y-%m-%d')" || true | |
| git tag "v$DATE" -f || true | |
| - name: Push changes | |
| if: steps.check.outputs.updates == 'true' | |
| run: | | |
| git push origin master --force || true | |
| git push origin "v$(date +%Y%m%d)" -f --tags || true |