-
Notifications
You must be signed in to change notification settings - Fork 161
129 lines (113 loc) · 3.85 KB
/
Copy pathdocsv2.yml
File metadata and controls
129 lines (113 loc) · 3.85 KB
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
122
123
124
125
126
127
128
129
name: Docs v2
on:
push:
branches:
- master
paths:
- "docs-v2/**"
pull_request:
branches:
- master
paths:
- "docs-v2/**"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-docsv2:
runs-on: ubuntu-latest
steps:
- name: Checkout files
uses: actions/checkout@v6
- name: Install Node v22
uses: actions/setup-node@v6
with:
node-version: "22"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v5
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-docsv2-${{ hashFiles('docs-v2/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-docsv2-
${{ runner.os }}-yarn-
- name: Install root JS dependencies
run: yarn install --immutable
- name: Build Docs v2
run: yarn build:docsv2
- name: Create artifacts
if: github.ref == 'refs/heads/master'
run: |
echo "Creating artifacts directory..."
mkdir -p artifacts
echo "Contents of docs-v2 directory:"
ls -la docs-v2/
echo "Moving dist to artifacts/docsv2..."
mv docs-v2/dist artifacts/docsv2
echo "Artifacts created successfully:"
ls -la artifacts/docsv2
- name: Upload docs v2
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v7
with:
name: docsv2-${{ github.sha }}
path: ./artifacts/
publish-docsv2:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
environment: master_n_tags
needs: [build-docsv2]
steps:
- uses: actions/checkout@v6
with:
ref: gh-pages
- uses: actions/create-github-app-token@v3
id: app-token
with:
app-id: ${{ secrets.GH_APP_SAS_APP_ID }}
private-key: ${{ secrets.GH_APP_SAS_APP_KEY }}
- name: Download docs v2
uses: actions/download-artifact@v8
with:
name: docsv2-${{ github.sha }}
path: tmp/
- name: Check files and deploy
run: |
echo "Current gh-pages branch contents:"
ls -la
echo "Downloaded artifacts:"
ls -la tmp/
echo "Removing old docsv2 directory..."
rm -rf docsv2/
echo "Moving new docsv2 build..."
mv tmp/docsv2/ docsv2/
rm -rf tmp/
echo "New docsv2 contents:"
ls -la docsv2/
echo "Git status:"
git status
- name: Push changes to gh-pages
env:
TOKEN: ${{ steps.app-token.outputs.token }}
APP_NAME: "paritytech-upd-ghpages-sas"
REF_NAME: ${{ github.head_ref || github.ref_name }}
Green: "\e[32m"
NC: "\e[0m"
run: |
echo "${Green}Git add${NC}"
git add docsv2/
echo "${Green}git status | wc -l${NC}"
git status | wc -l
echo "${Green}Add new remote with gh app token${NC}"
git remote set-url origin $(git config remote.origin.url | sed "s/github.com/${APP_NAME}:${TOKEN}@github.com/g")
echo "${Green}Remove http section that causes issues with gh app auth token${NC}"
sed -i.bak '/\[http/d' ./.git/config
sed -i.bak '/extraheader/d' ./.git/config
echo "${Green}Git push${NC}"
git config user.email "ci@parity.io"
git config user.name "${APP_NAME}"
git commit -m "___Updated docs v2" || echo "___Nothing to commit___"
git push origin gh-pages --force