-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (60 loc) · 2.34 KB
/
summarize.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Add CTAs and summaries to articles
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1'
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Set up GitHub CLI
run: |
curl -sSL https://github.com/cli/cli/releases/download/v2.0.0/gh_2.0.0_linux_amd64.tar.gz -o ghcli.tar.gz
tar xzf ghcli.tar.gz
sudo mv gh_*/bin/gh /usr/local/bin/
rm -rf gh_2.0.0_linux_amd64/ ghcli.tar.gz
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # This will get the latest version of Python 3
- name: Create a new branch and make changes
run: |
git config user.name 'GitHub Actions Bot'
git config user.email '[email protected]'
branch_name="automated-changes-$(date +'%d%m%Y')" # create a branch name based on the current day/month/year
git checkout -b $branch_name
pip install -r ./util/sgpt/requirements.txt
python ./util/sgpt/excerpt.py --dir ./blog/_posts
python ./util/sgpt/topcta.py --dir ./blog/_posts
git restore ./blog/_posts/2029-01-01-checklist.md
npm install -g markdownlint-cli
markdownlint --fix "./blog/_posts/*.md" || true
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Check for changes
id: changes
run: |
git diff --exit-code || echo "::set-output name=has_changes::true"
- name: Commit changes
if: steps.changes.outputs.has_changes == 'true'
run: |
git add -A
git commit -m "Automated code changes"
- name: Push changes and create PR
if: steps.changes.outputs.has_changes == 'true'
run: |
branch_name="automated-changes-$(date +'%d%m%Y')" # re-define branch name since we're in a new step
git push --force --set-upstream origin HEAD:$branch_name
gh auth login --with-token <<< "${{ secrets.GH_PAT }}"
gh pr create --base main --head $branch_name --title "Automated PR: Excerpt and Summary" --body "This is an automated PR."
env:
GH_CLI_TOKEN: ${{ secrets.GH_PAT }}