Timelapse #2257
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: Timelapse | |
| on: | |
| schedule: | |
| - cron: '0 1 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| timelapse: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-node@v1 | |
| with: | |
| node-version: 22.x | |
| - name: Install emoji support | |
| run: | | |
| sudo apt-get install fonts-noto-color-emoji fonts-noto -y | |
| - run: yarn --frozen-lockfile | |
| - run: node main capture-all | |
| - run: node main update | |
| - run: node main commit | |
| env: | |
| GIT_COMMITTER_NAME: dtinth-bot | |
| GIT_AUTHOR_NAME: dtinth-bot | |
| EMAIL: dtinth-bot@users.noreply.github.com | |
| - name: Save changed files | |
| run: | | |
| git diff --name-only origin/master | tee /tmp/changes.filelist.txt | |
| - name: git push | |
| run: | | |
| git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git" "$GITHUB_REF" | |
| - run: | | |
| node << 'EOF' | |
| const fs = require('fs') | |
| const { execSync } = require('child_process') | |
| const filelist = "/tmp/changes.filelist.txt" | |
| const changed = (fs.existsSync(filelist) && fs.readFileSync("/tmp/changes.filelist.txt", "utf-8").match(/\S+\.png/g)) || [] | |
| const head = String(execSync('git rev-parse HEAD')).trim() | |
| for (const filename of changed) { | |
| console.log(filename) | |
| const url = `https://github.com/${{ github.repository }}/raw/${head}/${filename}` | |
| const input = JSON.stringify({ | |
| text: `Updated ${filename}`, | |
| blocks: [{ type: 'image', alt_text: 'Screenshot', title: { type: 'plain_text', text: filename }, image_url: url }] | |
| }) | |
| console.log(input) | |
| try { | |
| execSync('curl -X POST -H "Content-type: application/json" -d @- "${{ secrets.SLACK_WEBHOOK_URL }}"', { | |
| input, | |
| stdio: ['pipe', 'inherit', 'inherit'] | |
| }) | |
| } catch (error) { | |
| console.error(error) | |
| } | |
| } | |
| EOF |