Update CImg #29
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 CImg | |
| on: | |
| schedule: | |
| - cron: 0 0 3 * * # The first day after this workflow was merged | |
| workflow_dispatch: | |
| jobs: | |
| check-version: | |
| name: Check for updates | |
| runs-on: ubuntu-latest | |
| outputs: | |
| latest-tag: ${{ steps.latest-tag.outputs.result }} | |
| steps: | |
| - name: Fetch the latest tag (could be buggy) | |
| uses: actions/github-script@v7 | |
| id: latest-tag | |
| with: | |
| result-encoding: string | |
| script: | | |
| return (await (Promise.all( [ github.rest.repos.listTags({ owner: 'GreycLab', repo: 'CImg', per_page: 28 }), | |
| github.rest.repos.listCommits({ owner: 'stefanhaustein', repo: 'TerminalImageViewer', per_page: 1, author: 'actions-user' }) | |
| ] ).then( ( values ) => { | |
| console.log( values[0].data[27].name ); | |
| console.log( values[1].data[0].commit.message.slice( 15 ) ); | |
| if( values[0].data[27].name === values[1].data[0].commit.message.slice( 15 ) ) return ""; | |
| return values[0].data[27].name; | |
| } ) ) ); | |
| - name: debug | |
| run: echo ${{ needs.check-version.outputs.latest-tag }} | |
| pull-file: | |
| name: Update CImg.h | |
| runs-on: ubuntu-latest | |
| needs: check-version | |
| if: ${{ needs.check-version.outputs.latest-tag != '' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| name: Checkout this repository | |
| - name: Download new CImg version | |
| uses: carlosperate/download-file-action@v2 | |
| with: | |
| file-url: 'https://github.com/GreycLab/CImg/raw/${{ needs.check-version.outputs.latest-tag }}/CImg.h' | |
| location: 'src' | |
| - name: Commit new CImg version | |
| run: | | |
| git config user.name 'GitHub Actions' | |
| git config user.email 'actions@github.com' | |
| git commit -am "Update CImg to ${{ needs.check-version.outputs.latest-tag }}" | |
| git push |