-
Notifications
You must be signed in to change notification settings - Fork 6
71 lines (62 loc) · 2.1 KB
/
update-portfolio-index.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
name: Update and deploy portfolio index site
on:
push:
branches: [main]
paths:
- '.github/workflows/update-portfolio-index.yml'
- 'portfolio/**'
pull_request:
paths:
- '.github/workflows/update-portfolio-index.yml'
- 'portfolio/**'
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install python packages
run: |
pip install -r portfolio/requirements.txt
- name: Netlify docs preview
if: ${{ github.ref != 'refs/heads/main' }}
run: |
npm install -g [email protected]
jb build -W -n --keep-going ./portfolio
netlify deploy \
--alias="${GITHUB_REPOSITORY#*/}-${{ github.event.number }}" \
--auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \
--dir="portfolio/index" \
--site=${{ secrets.NETLIFY_PREVIEW_APP_SITE_ID }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_PREVIEW_APP_SITE_ID }}
PR_NUMBER: ${{ github.event.number }}
- name: Netlify docs production
if: ${{ github.ref == 'refs/heads/main' }}
run: |
npm install -g [email protected]
python portfolio/portfolio.py index --deploy --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- name: Add netlify link PR comment
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const suffix = "--cal-itp-data-analyses.netlify.app"
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Preview url: https://" + context.repo.repo + "-" + process.env.PR_NUMBER + suffix
})
env:
PR_NUMBER: ${{ github.event.number }}