Update all non-major dev-dependencies #4661
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: Deploy PR build and run Lighthouse | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
if_key_exists: replace | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.8.1 | |
cache: "yarn" | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: "latest" | |
extended: true | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Clone ocw-www for content | |
run: (cd ..; git clone [email protected]:ocw-content-rc/ocw-www.git ocw-www) | |
- name: Clone ocw-course for content | |
run: (cd ..; git clone [email protected]:ocw-content-rc/15.s21-january-iap-2014.git ocw-course) | |
- name: Clone ocw-hugo-projects for config | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
repository: "mitodl/ocw-hugo-projects" | |
ref: "main" | |
path: "ocw-hugo-projects" | |
- name: Run webpack build | |
run: npm run build:webpack -- --output-path=../ocw-www/public/static_shared/ | |
- name: Copy webpack build to course v2 | |
run: mkdir -p ../ocw-course/public-v2/ && cp -r ../ocw-www/public/static_shared/ ../ocw-course/public-v2/ | |
- name: Run the www hugo build | |
run: (cd ../ocw-www; hugo --config $GITHUB_WORKSPACE/ocw-hugo-projects/ocw-www/config.yaml --themesDir ../ocw-hugo-themes) | |
env: | |
OCW_STUDIO_BASE_URL: ${{ secrets.OCW_STUDIO_BASE_URL }} | |
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }} | |
OCW_COURSE_STARTER_SLUG: ${{ secrets.OCW_COURSE_STARTER_SLUG }} | |
STATIC_API_BASE_URL: ${{ secrets.STATIC_API_BASE_URL }} | |
RESOURCE_BASE_URL: ${{ secrets.RESOURCE_BASE_URL }} | |
- name: Run the course v2 hugo build | |
run: (cd ../ocw-course; hugo --config $GITHUB_WORKSPACE/ocw-hugo-projects/ocw-course-v2/config.yaml --destination public-v2 --themesDir ../ocw-hugo-themes) | |
env: | |
OCW_STUDIO_BASE_URL: ${{ secrets.OCW_STUDIO_BASE_URL }} | |
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }} | |
OCW_COURSE_STARTER_SLUG: ${{ secrets.OCW_COURSE_STARTER_SLUG }} | |
STATIC_API_BASE_URL: ${{ secrets.STATIC_API_BASE_URL }} | |
RESOURCE_BASE_URL: ${{ secrets.RESOURCE_BASE_URL }} | |
- name: Deploy www Preview to Netlify | |
uses: nwtgck/[email protected] | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
publish-dir: "../ocw-www/public" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Deploy from GitHub Actions" | |
enable-pull-request-comment: false | |
enable-commit-comment: false | |
overwrites-pull-request-comment: false | |
alias: ocw-hugo-themes-www-pr-${{ github.event.number }} | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
- name: Deploy v2 Course Preview to Netlify | |
uses: nwtgck/[email protected] | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
publish-dir: "../ocw-course/public-v2" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Deploy from GitHub Actions" | |
enable-pull-request-comment: false | |
enable-commit-comment: false | |
overwrites-pull-request-comment: false | |
alias: ocw-hugo-themes-course-v2-pr-${{ github.event.number }} | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
- name: Set comment body | |
id: set-comment-body | |
run: | | |
body=$(echo 'Netlify Deployments:<br>www: https://ocw-hugo-themes-www-pr-${{ github.event.number }}--ocw-next.netlify.app/ <br> Course v2: https://ocw-hugo-themes-course-v2-pr-${{ github.event.number }}--ocw-next.netlify.app/') | |
echo "body=$body" >> $GITHUB_OUTPUT | |
- name: Find Comment | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
continue-on-error: true | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: "Netlify Deployments" | |
- name: Create comment | |
if: ${{ steps.fc.outputs.comment-id == 0 }} | |
uses: peter-evans/create-or-update-comment@v3 | |
continue-on-error: true | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: ${{ steps.set-comment-body.outputs.body }} | |
- name: Update comment | |
if: ${{ steps.fc.outputs.comment-id != 0 }} | |
uses: peter-evans/create-or-update-comment@v3 | |
continue-on-error: true | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
edit-mode: replace | |
body: ${{ steps.set-comment-body.outputs.body }} | |
- name: Deploy CI build to Netlify | |
uses: nwtgck/[email protected] | |
if: ${{ github.event_name == 'push' }} | |
with: | |
publish-dir: "../ocw-www/public" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Deploy from GitHub Actions" | |
enable-pull-request-comment: false | |
enable-commit-comment: false | |
production-deploy: true | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
lighthouse: | |
needs: build | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' }} | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.8.1 | |
cache: "yarn" | |
- run: mkdir -p ${{ github.workspace }}/tmp/artifacts | |
- name: Run Lighthouse | |
uses: foo-software/lighthouse-check-action@master | |
with: | |
branch: ${{ github.ref }} | |
outputDirectory: ${{ github.workspace }}/tmp/artifacts | |
urls: "https://ocw-hugo-themes-www-pr-${{ github.event.number }}--ocw-next.netlify.app/,https://ocw-hugo-themes-www-pr-${{ github.event.number }}--ocw-next.netlify.app/search/,https://ocw-hugo-themes-course-v2-pr-${{ github.event.number }}--ocw-next.netlify.app/" | |
sha: ${{ github.sha }} | |
accessToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: Lighthouse reports | |
path: ${{ github.workspace }}/tmp/artifacts |