-
Notifications
You must be signed in to change notification settings - Fork 56
72 lines (69 loc) · 3.18 KB
/
forked-pr-deploy.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
name: Deploy for Forked PR
on: status
jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Dump Github context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout
if: "endsWith(github.event.context, 'ci/circleci: build') && github.event.state == 'success'"
uses: actions/checkout@v2
- name: Setup Python
if: "endsWith(github.event.context, 'ci/circleci: build') && github.event.state == 'success'"
uses: actions/setup-python@v1
with:
python-version: '3.9'
- name: Download Build
if: "endsWith(github.event.context, 'ci/circleci: build') && github.event.state == 'success'"
id: build_download
run: |
echo "==== $(date): Starting pipenv setup... ===="
pip install pipenv
pipenv install
echo "==== $(date): Download build site... ===="
pipenv run ./content-repo/download_site_build.py -e "$GITHUB_EVENT_PATH"
- name: Setup Node
if: "steps.build_download.outputs.forked_pr > 0"
uses: actions/setup-node@v1
with:
node-version: '16.x'
# - name: Deploy Netlify Build
# if: "steps.build_download.outputs.forked_pr > 0"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# FORKED_PR: ${{ steps.build_download.outputs.forked_pr }}
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# run: |
# echo "==== $(date): extract build zip... ===="
# tar xzf build-site.tar.gz
# echo "==== $(date): Starting Netlify install... ===="
# npm install -g netlify-cli
# echo "==== $(date): Netlify deploy... ===="
# netlify deploy -m "CircleCI forked pr build: $FORKED_PR" -d build --alias=pull-request-$FORKED_PR --json > deploy-info.json
# cat deploy-info.json
# echo "==== $(date): Posting comment to PR ... ===="
# PR_NUM=$FORKED_PR pipenv run ./content-repo/post_github_comment.py deploy-info.json
- name: Deploy Firebase Build
if: "steps.build_download.outputs.forked_pr > 0"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORKED_PR: ${{ steps.build_download.outputs.forked_pr }}
FIREBASE_JSON_KEY: ${{ secrets.FIREBASE_JSON_KEY }}
run: |
echo "==== $(date): extract build zip... ===="
tar xzf build-site.tar.gz
echo "==== $(date): Starting Firebase install... ===="
echo $FIREBASE_JSON_KEY > "$HOME"/gcloud.json
npm install firebase-tools@~11.0.1
export GOOGLE_APPLICATION_CREDENTIALS="$HOME"/gcloud.json
export PATH="$PATH:`pwd`/node_modules/.bin"
echo "==== $(date): Firebase deploy for PR: $FORKED_PR ... ===="
firebase hosting:channel:deploy "pull-request-$FORKED_PR" --only xsoar.pan.dev > deploy-info-firebase.txt
cat deploy-info-firebase.txt
echo "==== $(date): Posting comment to PR ... ===="
PR_NUM=$FORKED_PR pipenv run ./content-repo/post_github_comment.py deploy-info-firebase.txt