-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (79 loc) · 2.52 KB
/
PREview-create.yaml
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
name: "PREview: Create"
on:
pull_request:
types: [opened, reopened]
jobs:
create-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: mshick/add-pr-comment@v2
with:
message: |
**Starting creation of the PREview environment...**
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true
- name: Obtain Bucket Name
uses: ./.github/actions/PREview-data
- name: Authenticate with Google Cloud
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{secrets.GCP_SERVICE_ACCOUNT}}"
- name: "Set up Cloud SDK"
uses: "google-github-actions/setup-gcloud@v2"
- name: Create PReview bucket
run: gsutil mb gs://${BUCKET}
- name: Configure bucket for public access
run: gsutil iam ch allUsers:legacyObjectReader gs://${BUCKET}
- name: Configure bucket web properties
run: gsutil web set -m index.html -e 404.html gs://${BUCKET}
- uses: mshick/add-pr-comment@v2
if: success()
continue-on-error: true
with:
message: |
**PREview environment has been created at [${{ env.URL }}](${{ env.URL }})**
*Please allow a few minutes for the environment to be fully deployed.*
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true
data:
runs-on: ubuntu-latest
outputs:
URL: ${{ steps.data.outputs.URL }}
BUCKET: ${{ steps.data.outputs.BUCKET }}
BRANCH: ${{ steps.data.outputs.BRANCH }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Obtain URL
id: data
uses: ./.github/actions/PREview-data
build:
uses: ./.github/workflows/_build.yaml
with:
output_dir: build
secrets: inherit
deploy-update:
needs: [data, build]
uses: ./.github/workflows/_deploy.yaml
with:
src_dir: build
bucket: ${{ needs.data.outputs.BUCKET }}/docs
secrets: inherit
notify:
runs-on: ubuntu-latest
needs: [deploy-update]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Obtain Bucket Name
uses: ./.github/actions/PREview-data
- uses: mshick/add-pr-comment@v2
if: success()
continue-on-error: true
with:
message: |
**PREview has been updated at ${{ env.URL }}**
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: true