Radar/2024 (#8) #85
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: Main Workflow | |
on: [push, pull_request] | |
jobs: | |
build_deploy_preview: | |
name: Build & Deploy (Preview) | |
runs-on: ubuntu-latest | |
if: github.ref != 'refs/heads/main' && github.actor != 'dependabot[bot]' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
# @see https://www.voorhoede.nl/en/blog/super-fast-npm-install-on-github-actions/ | |
- uses: actions/cache@v3 | |
id: cache-node-modules | |
with: | |
path: ./node_modules | |
key: ${{ runner.os }}-modules-${{ hashFiles('package-lock.json') }} | |
- name: Install packages | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- uses: gacts/github-slug@v1 | |
id: slug | |
- run: | | |
echo "BRANCH_NAME_SLUG=${{ steps.slug.outputs.branch-name-slug }}" >> $GITHUB_ENV | |
echo "DEPLOY_URL=https://${{ steps.slug.outputs.branch-name-slug }}--inventage-tech-radar.netlify.app" >> $GITHUB_ENV | |
echo "GITHUB_SHA_SHORT=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV | |
- name: Build | |
run: npm run build | |
# Use netlify-cli directly, since it is installed in the latest ubuntu runner | |
# @see https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#cli-tools | |
# @see https://cli.netlify.com/commands/deploy/ | |
- name: Deploy | |
id: deploy | |
run: | | |
netlify deploy \ | |
--alias ${{ env.BRANCH_NAME_SLUG }} \ | |
--build false \ | |
--dir build \ | |
--message 'Preview deployment for ${{ steps.slug.outputs.branch-name }} (${{ env.GITHUB_SHA_SHORT }})' \ | |
--prod false \ | |
--json true | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
- name: Comment PR | |
uses: thollander/actions-comment-pull-request@v2 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
message: | | |
Deployed to ${{ env.DEPLOY_URL }} | |
comment_tag: deployment | |
build_deploy: | |
name: Build & Deploy | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && github.actor != 'dependabot[bot]' | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
# @see https://www.voorhoede.nl/en/blog/super-fast-npm-install-on-github-actions/ | |
- uses: actions/cache@v3 | |
id: cache-node-modules | |
with: | |
path: ./node_modules | |
key: ${{ runner.os }}-modules-${{ hashFiles('package-lock.json') }} | |
- name: Install packages | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./build | |
cname: techradar.inventage.com |