-
Notifications
You must be signed in to change notification settings - Fork 22
87 lines (71 loc) · 2.53 KB
/
update-api.yml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Update API
on:
workflow_dispatch:
permissions:
actions: write
contents: write
pull-requests: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
update-api:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Read package.json
id: package
uses: juliangruber/read-file-action@v1
with:
path: ./package.json
- name: Cache PNPM modules
uses: actions/cache@v4
id: cache-modules
with:
path: |
~/.pnpm-store
node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-node-
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
# use the version found in `.nvmrc`
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install `node_modules`
if: steps.cache-modules.outputs.cache-hit != 'true'
run: pnpm install
- name: Copy `.env.test` -> `.env`
run: cp .env.test .env
- name: Build the `.nuxt` directory
run: pnpm build
- name: Run the API generation
run: pnpm run generate:api --url=${{ vars.OPENAPI_URL }}
- name: Set git configs
run: |
git config user.email "[email protected]"
git config user.name "API Updater"
- name: Set branch name
id: branch
run: echo "BRANCH_NAME=chore-update-api-$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Add changes, commit, and push
run: |
git checkout -b ${{ steps.branch.outputs.BRANCH_NAME }}
pnpm pretty:staged
git add ./lib
git commit -m 'chore: lib: update api' --no-verify
git remote set-url origin https://api-updater:${{ secrets.GITHUB_TOKEN }}@github.com/leaderboardsgg/leaderboard-site.git
git push origin ${{ steps.branch.outputs.BRANCH_NAME }}
- name: Create PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.WORKFLOW_ACCESS_TOKEN }}
script: |
await github.rest.pulls.create({
owner: 'leaderboardsgg',
repo: 'leaderboard-site',
base: 'main',
head: '${{ steps.branch.outputs.BRANCH_NAME }}',
title: 'chore: Update API',
})