Skip to content

Commit 5280375

Browse files
committed
CI: auto deploy to vercel
1 parent d726d9a commit 5280375

File tree

4 files changed

+143
-6
lines changed

4 files changed

+143
-6
lines changed

.github/dependabot.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
version: 2
22
updates:
3-
- package-ecosystem: composer
4-
directory: "/php-composer"
5-
schedule:
6-
interval: daily
7-
time: '13:00'
8-
open-pull-requests-limit: 10
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: daily

.github/workflows/deploy-php.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Deploy avatarless
2+
3+
on:
4+
push:
5+
paths:
6+
- 'php/**'
7+
branches:
8+
- "master"
9+
10+
concurrency:
11+
group: php-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
deploy:
16+
name: Deploy php
17+
uses: ./.github/workflows/vercel.yml
18+
secrets: inherit
19+
with:
20+
projectId: "QmUCScRKnp9ciJXA5Rucs9Wx6p3i4YnWvbKUqtvZNX8PcH"
21+
projectPath: "php"

.github/workflows/main.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Compile"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "*"
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
run:
15+
name: Run
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Use Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 16.x
25+
26+
- name: Cache Node.js
27+
uses: actions/cache@v3
28+
with:
29+
path: '**/node_modules'
30+
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
31+
32+
- name: NPM install
33+
run: npm install
34+
35+
- name: Lerna install
36+
run: npx lerna bootstrap --no-ci
37+
38+
- name: Lerna compile
39+
run: npx lerna run compile

.github/workflows/vercel.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Deploy Vercel
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
projectPath:
7+
required: true
8+
type: string
9+
default: "tests"
10+
11+
projectId:
12+
required: true
13+
type: string
14+
15+
orgId:
16+
required: false
17+
type: string
18+
default: "team_IkoklT80okK0VAeKnM87wuvk"
19+
20+
jobs:
21+
deploy:
22+
name: "Deploy ${{ inputs.projectPath }}"
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Use Node.js
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: 18.x
33+
34+
- name: Cache Node.js
35+
uses: actions/cache@v3
36+
with:
37+
path: '**/node_modules'
38+
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
39+
40+
- name: Install Vercel
41+
run: |
42+
npm i -g vercel
43+
44+
- name: Setup ENV
45+
id: setup
46+
run: |
47+
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
48+
49+
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
50+
echo "args=--prod" >> $GITHUB_OUTPUT
51+
fi
52+
- name: Debug
53+
run: |
54+
echo "::debug::Branch ${{steps.setup.outputs.branch}}"
55+
echo "::debug::Args ${{steps.setup.outputs.args}}"
56+
57+
- name: Deploy
58+
id: vercel
59+
env:
60+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
61+
VERCEL_PROJECT_ID: ${{ inputs.projectId }}
62+
VERCEL_ORG_ID: ${{ inputs.orgId }}
63+
run: |
64+
vercel \
65+
-t ${{ secrets.VERCEL_TOKEN }} \
66+
-m githubCommitSha=${GITHUB_SHA} \
67+
-m githubCommitAuthorName=${{ github.event.sender.login }} \
68+
-m githubCommitAuthorLogin=f3l1x \
69+
-m githubDeployment=1 \
70+
-m githubOrg=${{ github.event.repository.owner.name }} \
71+
-m githubRepo=${{ github.event.repository.name }} \
72+
-m githubRepoId=${{ github.event.repository.id }} \
73+
-m githubCommitOrg=${{ github.event.repository.owner.name }} \
74+
-m githubCommitRepo=${{ github.event.repository.name }} \
75+
-m githubCommitRepoId=${{ github.event.repository.id }} \
76+
-m githubCommitMessage="${{ github.event.head_commit.message }}" \
77+
-m githubCommitRef=${{steps.setup.outputs.branch}} \
78+
--cwd ${{ inputs.projectPath }} \
79+
${{steps.setup.outputs.args}}

0 commit comments

Comments
 (0)