Build and Publish #73
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: Build and Publish | |
on: | |
schedule: | |
- cron: '0 0 * * *' # This will run the action daily at midnight. | |
workflow_dispatch: # This allows for manual triggering of the workflow. | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install Dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
env: | |
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }} | |
- name: Check for changes | |
run: | | |
git diff --quiet && exit 0 || echo "Changes detected!" | |
- name: Run Tests | |
run: npm test | |
- name: Commit changes before npm publish | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add -A | |
git commit -m "Build artifacts" || echo "No changes to commit" | |
git push | |
- name: Publish to npm | |
run: npm version minor --force && npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Commit changes after npm publish | |
run: | | |
git add -A | |
git commit -m "Bump version in package.json" || echo "No changes to commit" | |
git push | |