Skip to content

Commit a5de7df

Browse files
Copilotmingrammer
andauthored
[WIP] Update GitHub Actions workflow for improved CI (#94)
* Initial plan * Update GitHub Actions workflow with modern versions and improved logic Co-authored-by: mingrammer <6178510+mingrammer@users.noreply.github.com> * Improve token security and use specific Go version Co-authored-by: mingrammer <6178510+mingrammer@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mingrammer <6178510+mingrammer@users.noreply.github.com>
1 parent 44b28e0 commit a5de7df

1 file changed

Lines changed: 33 additions & 20 deletions

File tree

.github/workflows/main.yml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,41 @@ name: update
33
on:
44
schedule:
55
- cron: "0 0 * * SUN"
6+
workflow_dispatch:
67

78
jobs:
89
build:
910
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
1013
steps:
11-
- uses: actions/checkout@v1
12-
with:
13-
ref: "master"
14-
- uses: actions/setup-go@v1
15-
with:
16-
go-version: "1.13"
17-
- run: |
18-
echo ${{ secrets.GITHUB_TOKEN }} >> access_token.txt
19-
go run list2md.go
20-
- name: update the list
21-
env:
22-
GITHUB_USER: "mingrammer"
23-
GITHUB_EMAIL: "mingrammer@gmail.com"
24-
run: |
25-
git config user.name "${GITHUB_USER}"
26-
git config user.email "${GITHUB_EMAIL}"
27-
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git
28-
git checkout master
29-
git commit -am "chore: auto update"
30-
git push -u origin master
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: "master"
17+
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version: "1.21.x"
21+
22+
- name: Create access token file
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: echo "$GITHUB_TOKEN" > access_token.txt
26+
27+
- name: Run update script
28+
run: go run list2md.go
29+
30+
- name: Update the list
31+
env:
32+
GITHUB_USER: "mingrammer"
33+
GITHUB_EMAIL: "mingrammer@gmail.com"
34+
run: |
35+
git config user.name "${GITHUB_USER}"
36+
git config user.email "${GITHUB_EMAIL}"
37+
git add -A
38+
if git diff --staged --quiet; then
39+
echo "No changes to commit"
40+
exit 0
41+
fi
42+
git commit -m "chore: auto update"
43+
git push

0 commit comments

Comments
 (0)