github repo workflow changes #334
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
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 }} |