forked from ballerina-platform/ballerina-dev-website
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 2.15 KB
/
pre-prod_sync.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
name: Deploy Nextjs app to gh-pages
on:
workflow_dispatch:
inputs:
source_branch:
description: ballerina-dev-website repo branch
required: true
default: master
jobs:
build:
runs-on: macos-latest
env:
NEXT_PUBLIC_BASE_PATH: ""
GITHUB_TOKEN: ${{ secrets.WEBSITE_TOKEN }}
strategy:
matrix:
node-version: [16.x]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.source_branch }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Checkout gh-pages
run: |
mkdir gh-pages
cd gh-pages
git init
git remote add origin https://ballerina-bot:$GITHUB_TOKEN@github.com/ballerina-platform/ballerina-dev-website.git
git fetch origin
git checkout -b deploy-website-$GITHUB_SHA origin/gh-pages
- name: Export static files
run: npm run export
- name: Add .nojekyll file
run: touch out/.nojekyll
- name: Rearrange files to match the urls
run: |
chmod +x utils/rearrangeFiles.sh
utils/rearrangeFiles.sh
shell: bash
- name: Deploy
run: |
cp -r .github CNAME robots.txt gh-pages/.git utils out
cd out
git config --global user.email "ballerina-bot@ballerina.org"
git config --global user.name "ballerina-bot"
git add .
git commit --allow-empty -m 'Deploy website'
git push origin deploy-website-$GITHUB_SHA
echo 'Successfully pushed to deploy-website-$GITHUB_SHA branch'
- name: Create pull request for new site
shell: bash
run: |
cd out
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub pull-request -b gh-pages -m '[Automated] Deploy website'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}