Skip to content

Commit

Permalink
refactor: change Netlify CI action
Browse files Browse the repository at this point in the history
  • Loading branch information
tydeu committed Nov 28, 2023
1 parent 19a54d4 commit 806982f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
name: Deploy
environment:
name: netlify
url: ${{ github.ref_name == 'master' && steps.publish.outputs.NETLIFY_LIVE_URL || steps.publish.outputs.NETLIFY_URL }}
url: ${{ steps.publish.outputs.deploy-url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -81,16 +81,23 @@ jobs:
run: npm ci
- name: Build Site
run: npm run generate
- id: alias
name: Compute Deploy Alias
if: github.ref_name != 'master'
run: python3 -c 'import base64; print("alias="+base64.urlsafe_b64encode(bytes.fromhex("${{github.sha}}")).decode("utf-8").rstrip("="))' >> "$GITHUB_OUTPUT"
- id: deploy-info
name: Compute Deploy Info
run: |
set -e
python3 -c 'import base64; print("alias="+base64.urlsafe_b64encode(bytes.fromhex("${{github.sha}}")).decode("utf-8").rstrip("="))' >> "$GITHUB_OUTPUT"
(echo "message="; git log -1 --pretty=format:"%s") >> "$GITHUB_OUTPUT"
- id: publish
name: Publish
uses: netlify/actions/cli@master
name: Publish to Netlify
uses: nwtgck/actions[email protected]
with:
args: deploy --dir=.output/public \
${{ github.ref_name == 'master' && '--prod' || format('--alias={0}', steps.alias.outputs.alias) }}
publish-dir: .output/public
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: |
${{ github.event_name == 'pull_request' && format('pr {0}: {1}', github.event.number, steps.deploy-info.outputs.message) || steps.deploy-info.outputs.message }}
alias: ${{ steps.deploy-info.outputs.alias }}
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1

0 comments on commit 806982f

Please sign in to comment.