Skip to content

Timelapse

Timelapse #1822

Workflow file for this run

name: Timelapse
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
timelapse:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install emoji support
run: |
sudo apt-get install fonts-noto-color-emoji fonts-noto -y
- run: yarn
- 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: [email protected]
- 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