-
Notifications
You must be signed in to change notification settings - Fork 29
121 lines (110 loc) · 4.93 KB
/
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Hugo Website Deploy
on:
issue_comment:
types: [created, edited]
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
type: choice
required: true
default: 'staging'
options:
- staging
- production
push:
branches:
- main
jobs:
deploy_staging:
if: |
(github.event.issue.pull_request && contains('["nuclearcat","JenySadadia","a-wai","broonie","padovan", "patersonc"]', github.actor) && contains(github.event.comment.body, '/staging')) ||
(github.event_name == 'workflow_dispatch' && contains('["nuclearcat","JenySadadia","a-wai","broonie","padovan", "patersonc"]', github.actor)) ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-22.04
environment: stagingdeploy
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
if: github.event_name == 'issue_comment'
with:
submodules: recursive # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
lfs: true # Fetch Git LFS files
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Checkout main branch
uses: actions/checkout@v4
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
with:
submodules: recursive # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
lfs: true # Fetch Git LFS files
ref: main
# TODO: Fix this more elegantly
- name: Submodules init
run: git submodule update --init --recursive
- name: Update submodule kernelci-pipeline
run: cd kernelci.org/external/kernelci-pipeline;git pull origin main
- name: Update submodule kernelci-api
run: cd kernelci.org/external/kernelci-api;git pull origin main
- name: Update submodule kernelci-core
run: cd kernelci.org/external/kernelci-core;git pull origin main
- name: Update submodule kcidb
run: cd kernelci.org/external/kcidb;git pull origin main
- name: Update submodule kci-dev
run: cd kernelci.org/external/kci-dev;git pull origin main
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.97.3'
extended: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies (postcss), bootstrap-sass
run: npm install --save-dev autoprefixer && npm install postcss-cli && npm install -D postcss && npm install -D postcss-preset-env && npm install -D bootstrap-sass
- name: Build staging
if: github.event.inputs.environment == 'staging' || github.event_name == 'issue_comment'
run: cd kernelci.org;hugo --minify -D -F -b https://static.staging.kernelci.org/
- name: Build production
if: github.event_name == 'push' || github.event.inputs.environment == 'production'
run: cd kernelci.org;hugo --minify -D -F -b https://kernelci.org/
- name: rsync staging deployment
if: github.event.inputs.environment == 'staging' || github.event_name == 'issue_comment'
uses: burnett01/[email protected]
with:
switches: -avzr --delete
path: kernelci.org/public/
remote_path: ${{ secrets.WEB_STAGING_DIR }}
remote_host: ${{ secrets.WEB_STAGING_HOST }}
remote_port: ${{ secrets.WEB_STAGING_PORT }}
remote_user: ${{ secrets.WEB_STAGING_USERNAME }}
remote_key: ${{ secrets.WEB_STAGING_KEY }}
- name: Leave comment in issue about staging URL
if: github.event.inputs.environment == 'staging' || github.event_name == 'issue_comment'
run: |
gh issue comment "$NUMBER" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
BODY: >
Your PR has been deployed to staging.
Staging URL: https://static.staging.kernelci.org/
After testing, you can merge your PR.
Note: This is a temporary staging URL, if anyone else will test another PR, it will override contents.
- name: rsync production deployment
if: github.event_name == 'push' || github.event.inputs.environment == 'production'
uses: burnett01/[email protected]
with:
switches: -avzr --delete
path: kernelci.org/public/
remote_path: ${{ secrets.WEB_PRODUCTION_DIR }}
remote_host: ${{ secrets.WEB_PRODUCTION_HOST }}
remote_port: ${{ secrets.WEB_PRODUCTION_PORT }}
remote_user: ${{ secrets.WEB_PRODUCTION_USERNAME }}
remote_key: ${{ secrets.WEB_PRODUCTION_KEY }}