update #69
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 | |
| permissions: | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '30 0 * * *' # every day at 12:30 AM | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - {file: check-staging.yaml} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.WORKFLOWS_TOKEN }} | |
| - name: Download snapshot.json. | |
| run: | | |
| curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3.raw" \ | |
| -o snapshot.json \ | |
| "https://api.github.com/repos/r-multiverse/staging/contents/snapshot.json" | |
| - name: Read values in snapshot.json. | |
| run: | | |
| echo "CRAN_URL=$(jq -r '.[0].cran' snapshot.json)" >> $GITHUB_ENV | |
| echo "R_VERSION=$(jq -r '.[0].r' snapshot.json)" >> $GITHUB_ENV | |
| - name: Replace wildcards with values in workflow scripts. | |
| run: | | |
| sed "s|CRAN_URL|${{ env.CRAN_URL }}|g" templates/${{ matrix.config.file }} | \ | |
| sed "s|R_VERSION|${{ env.R_VERSION }}|g" > .github/workflows/${{ matrix.config.file }} | |
| - name: Commit and push changes. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.WORKFLOWS_TOKEN }} | |
| run: | | |
| git config --global user.name github-actions | |
| git config --global user.email [email protected] | |
| git add .github/workflows/${{ matrix.config.file }} | |
| if git diff --quiet && git diff --staged --quiet; then | |
| echo "No changes to commit." | |
| else | |
| git commit -m "Update ${{ matrix.config.file }}" | |
| git push -u origin main | |
| fi |