Skip to content

github repo workflow changes #328

github repo workflow changes

github repo workflow changes #328

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.8
- 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]
netlify deploy \
--alias=${GITHUB_REPOSITORY#*/}-${PR_NUMBER} \
--auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \
--site=cal-itp-data-analyses \
--dir="portfolio/index"
env:
#NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
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 }}