-
Notifications
You must be signed in to change notification settings - Fork 2
66 lines (54 loc) · 2.05 KB
/
CI.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
name: Pull request Analysis and preview ( Mainnet )
# Notes:
# This pipeline will deploy the page on Cloudflare Pages ( direct upload ), Similar to a S3 bucket.
# You need to have the following secrets and variables defined in your repository:
# - PRODUCTION_ENV_NAME
# - PRODUCTION_ENV_URL
# - DEVELOPMENT_ENV_NAME
# - DEVELOPMENT_ENV_URL
# - CLOUDFLARE_API_TOKEN -> https://developers.cloudflare.com/workers/wrangler/ci-cd/#api-token
# - CLOUDFLARE_ACCOUNT_ID -> Request to devops team to get this value
on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize, edited, ready_for_review]
permissions:
pull-requests: write
actions: write
contents: read
jobs:
CI:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/Checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn' # You can choose npm|yarn|pnpm
- name: Install dependencies
run: yarn install # If you use npm, you would run: npm ci
- name: Build
run: yarn build
env:
NODE_ENV: development
# If we need, we can easily change thjis step to deploy to S3 bucket
- name: Deploy
id: deploy
uses: cloudflare/wrangler-action@v3
with:
packageManager: yarn
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
environment: Preview
command: pages deploy ./dist --project-name ${{ vars.PRODUCTION_ENV_NAME }} --branch ${{ env.GITHUB_REF_NAME }} --commit-hash ${{ env.GITHUB_SHA }}
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'You can preview the changes at : ${{ steps.deploy.outputs.deployment-url }}'
})