Skip to content

Commit 9c6b5ca

Browse files
author
Melissa Garcia
committed
add deploy scripts for stage
1 parent 5b6a27a commit 9c6b5ca

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
home="https://admin.hlx.page/preview/adobedocs/adp-devsite-stage/main"
4+
root=$1
5+
path_prefix=$2
6+
7+
publish()
8+
{
9+
filename=$1
10+
to_remove="$root/"
11+
relative_filename=${filename/#$to_remove}
12+
url="${home}${path_prefix}${relative_filename}"
13+
14+
echo ""
15+
echo "curl -XPOST -vi --header \"x-content-source-authorization: stage\" ${url}"
16+
curl -XPOST -vi --header "x-content-source-authorization: stage" "${url}"
17+
}
18+
19+
# TODO: may want to only certain types of files up
20+
find "${root}" -type f \( -name "*.md" -o -name "*.json" \) -exec echo "{}" \; | while read i; do publish $i; done
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: Deployment Stage
3+
on:
4+
workflow_dispatch
5+
6+
jobs:
7+
set-state:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
path_prefix: ${{ steps.get_path_prefix.outputs.path_prefix }}
11+
branch_short_ref: ${{ steps.get_branch.outputs.branch }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Get pathPrefix
17+
uses: actions/github-script@v6
18+
id: get_path_prefix
19+
with:
20+
script: |
21+
const script = require('./.github/scripts/get-path-prefix.js');
22+
script({ core });
23+
result-encoding: string
24+
- name: Get branch name
25+
shell: bash
26+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT"
27+
id: get_branch
28+
29+
echo-state:
30+
needs: [set-state]
31+
runs-on: ubuntu-latest
32+
steps:
33+
- run: echo "Repository org - ${{ github.event.repository.owner.login }}"
34+
- run: echo "Repository name - ${{ github.event.repository.name }}"
35+
- run: echo "Repository branch - ${{ needs.set-state.outputs.branch_short_ref }}"
36+
- run: echo "Path prefix - ${{ needs.set-state.outputs.path_prefix }}"
37+
38+
39+
build:
40+
defaults:
41+
run:
42+
shell: bash
43+
needs: [set-state]
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v3
48+
49+
- name: Setup Node v16 for Yarn v3
50+
uses: actions/setup-node@v3
51+
with:
52+
node-version: "16.15.0" # Current LTS version
53+
54+
- name: Enable Corepack for Yarn v3
55+
run: corepack enable
56+
57+
- name: Install Yarn v3
58+
uses: borales/actions-yarn@v3
59+
with:
60+
cmd: set version stable
61+
62+
- name: Install Dependencies
63+
uses: borales/actions-yarn@v3
64+
env:
65+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
66+
with:
67+
cmd: install
68+
69+
- name: Build navigation file
70+
uses: borales/actions-yarn@v3
71+
with:
72+
cmd: buildNavigation
73+
74+
- name: Publish markdown files in ./src/pages
75+
run: |
76+
bash .github/scripts/publish-mds-stage.sh "./src/pages" "${{ needs.set-state.outputs.path_prefix }}"

0 commit comments

Comments
 (0)