summaryrefslogtreecommitdiff
path: root/.github/workflows/check-commit.yml
blob: b1716c4f53cc10a5b284666e81992e1c67f18715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Get latest commit
on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

jobs:
  get-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: Fetch packwiz commit
        run: |
          curl -sL https://api.github.com/repos/packwiz/packwiz/commits | jq .[0].sha > current_commit.txt
      - name: Check for new commit
        id: git-check
        run: |
          echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")
      - name: Update cached commit
        if: steps.git-check.outputs.modified == 'true'
        run: |
          git config --global user.name 'github-actions'
          git config --global user.email '[email protected]'
          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
          
          git add current_commit.txt
          
          git commit -m "chore: update packwiz commit"
          git tag "$(date '+%Y%m%d')"
          
          git push
          git push --tags