Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Publish nightly

Publish nightly #231

name: Publish nightly
on:
workflow_dispatch: {}
repository_dispatch:
types: [publish-nightly]
schedule:
- cron: '0 0 * * *'
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/[email protected]
- name: Print Latest Commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: Check if latest commit is less than a day
# if: ${{ github.event_name == 'schedule' }}
run: |
COMMIT_DATE=$(git show -s --format=%ci ${{ github.sha }})
COMMIT_DATE=$(date -d "$COMMIT_DATE" +%s)
NOW=$(date +%s)
DIFF=$(($NOW - $COMMIT_DATE))
echo "Commit date: $COMMIT_DATE"
echo "Now: $NOW"
echo "Diff: $DIFF"
if [ $DIFF -lt 86400 ]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
fi
publish:
runs-on: ubuntu-latest
needs: check_date
if: ${{ needs.check_date.outputs.should_run == 'true' }}
steps:
- name: 'Checkout the repository'
uses: 'actions/checkout@v4'
- name: 'Setup Node.js and pnpm'
uses: './.github/actions/setup'
- name: 'Generate nightly package.json'
run: npm run config:prerelease -- nightly
- run: pnpm publish --tag nightly --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}