2020-07-07 15:50:29 +02:00
|
|
|
name: Up to Date
|
|
|
|
|
|
|
|
on:
|
|
|
|
schedule:
|
2023-07-22 13:19:36 +02:00
|
|
|
- cron: '0 0 * * *'
|
2020-07-07 15:50:29 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
update:
|
|
|
|
name: Update
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-07-22 13:19:36 +02:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: ./.github/actions/setup
|
|
|
|
- run: pnpm run generate
|
2020-07-07 15:50:29 +02:00
|
|
|
|
|
|
|
- name: Push New Cheat Sheet to Updated Branch
|
|
|
|
run: |
|
|
|
|
git diff --name-only --exit-code && exit 0
|
|
|
|
git add README.md
|
|
|
|
git config --global user.name "github-actions[bot]"
|
|
|
|
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
git commit -m "docs(readme): update emoji-cheat-sheet"
|
|
|
|
git push -qf "https://${{ secrets.GITHUB_TOKEN }}@github.com/ikatyang/emoji-cheat-sheet.git" HEAD:github-actions-auto-update
|
|
|
|
|
|
|
|
- name: Create PR from Updated Branch
|
|
|
|
uses: actions/github-script@v2
|
|
|
|
with:
|
|
|
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
|
|
|
script: |
|
|
|
|
const {owner, repo} = context.repo
|
|
|
|
const branch = 'github-actions-auto-update'
|
2021-10-17 05:58:07 +02:00
|
|
|
const head = `${owner}:${branch}`
|
2020-07-09 16:18:09 +02:00
|
|
|
const title = 'docs(readme): update emoji-cheat-sheet'
|
|
|
|
const branchesResult = await github.repos.listBranches({ owner, repo })
|
|
|
|
if (branchesResult.status !== 200 || !branchesResult.data.find(({ name }) => name === branch)) {
|
2020-07-07 15:50:29 +02:00
|
|
|
return
|
|
|
|
}
|
2021-10-17 05:58:07 +02:00
|
|
|
const prsResult = await github.pulls.list({ owner, repo, head, state: 'open' })
|
2020-07-09 16:18:09 +02:00
|
|
|
if (prsResult.status === 200 && prsResult.data.length === 0) {
|
2021-10-28 15:55:16 +02:00
|
|
|
try {
|
|
|
|
await github.pulls.create({ owner, repo, head, title, base: 'master' })
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
}
|
2020-07-07 15:50:29 +02:00
|
|
|
}
|