Skip to content

Commit 22a8dca

Browse files
committed
add update_clasp_token.yml
1 parent abf3a62 commit 22a8dca

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Weekly Clasp Token Update
2+
on:
3+
schedule:
4+
- cron: '0 0 * * 1' # Runs every Monday at 00:00 UTC
5+
workflow_dispatch: # Allows manual triggering for immediate testing
6+
jobs:
7+
weekly-update:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v4
12+
with:
13+
ref: 95-github-action-pre-push-hook # Chain to main when deploy
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: '16'
18+
- name: Install clasp
19+
run: npm install -g @google/clasp
20+
- name: Write CLASP_CREDENTIALS secret to .clasprc.json file
21+
run: |
22+
echo "${CLASP_CREDENTIALS}" > "${HOME}/.clasprc.json"
23+
env:
24+
CLASP_CREDENTIALS: ${{secrets.CLASPRC_JSON}}
25+
- name: Check clasp login status
26+
id: clasp_login
27+
run: clasp login --status
28+
29+
- name: Save current .clasprc.json contents to CLASPRC_JSON_FILE environment variable
30+
id: save-clasprc
31+
run: |
32+
echo ::add-mask::$(tr -d '\n\r' < ~/.clasprc.json)
33+
echo "CLASPRC_JSON_FILE=$(tr -d '\n\r' < ~/.clasprc.json)" >> $GITHUB_ENV
34+
35+
- name: Save CLASPRC_JSON_FILE environment variable to CLASPRC_JSON repo secret
36+
id: set-clasprc-secret
37+
if: ${{ env.CLASPRC_JSON_FILE != env.CLASPRC_JSON_SECRET }}
38+
uses: hmanzur/actions-set-secret@v2.0.0
39+
env:
40+
CLASPRC_JSON_SECRET: ${{ secrets.CLASPRC_JSON }}
41+
with:
42+
name: "CLASPRC_JSON"
43+
value: ${{ env.CLASPRC_JSON_FILE }}
44+
repository: ${{ github.repository }}
45+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
46+

0 commit comments

Comments
 (0)