π Create netlify-cd.yaml #2
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 to Netlify | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: | |
- "master" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Allow one concurrent deployment | |
concurrency: | |
group: "netlify" | |
cancel-in-progress: true | |
jobs: | |
# Single deploy job since we're just deploying | |
deploy: | |
environment: | |
name: Netlify | |
url: ${{ steps.netlify_deploy.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout master branch | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
- name: Install Netlify | |
run: npm install -g netlify-cli@17 | |
- name: Install dependencies | |
run: npm ci | |
- name: Build project | |
run: npm run build | |
- name: Deploy to Netlify | |
id: netlify_deploy | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
run: | | |
netlify deploy --prod --dir ./dist/ | |
echo "page_url=https://hello-preact.netlify.app" >> "$GITHUB_OUTPUT" |