|
| 1 | +name: Deploy to happycommits.dev |
| 2 | + |
| 3 | +on: |
| 4 | + # Runs on pushes targeting the default branch |
| 5 | + push: |
| 6 | + branches: ["main"] |
| 7 | + |
| 8 | + # Allows you to run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | + # Allows you to trigger this workflow from another workflow |
| 12 | + workflow_call: |
| 13 | + |
| 14 | + # Cron schedule, everyday at midnight |
| 15 | + schedule: |
| 16 | + - cron: '0 0 * * *' |
| 17 | + |
| 18 | + |
| 19 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 20 | +permissions: |
| 21 | + contents: write |
| 22 | + pages: write |
| 23 | + id-token: write |
| 24 | + |
| 25 | +# Allow one concurrent deployment |
| 26 | +concurrency: |
| 27 | + group: "pages" |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +jobs: |
| 31 | + # Build job |
| 32 | + build: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v3 |
| 37 | + - name: Setup Node |
| 38 | + uses: actions/setup-node@v3 |
| 39 | + with: |
| 40 | + node-version: "18" |
| 41 | + cache: ${{ steps.detect-package-manager.outputs.manager }} |
| 42 | + - name: Setup Pages |
| 43 | + uses: actions/configure-pages@v2 |
| 44 | + with: |
| 45 | + # Automatically inject basePath in your Next.js configuration file and disable |
| 46 | + # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). |
| 47 | + # |
| 48 | + # You may remove this line if you want to manage the configuration yourself. |
| 49 | + static_site_generator: next |
| 50 | + - name: Restore cache |
| 51 | + uses: actions/cache@v3 |
| 52 | + with: |
| 53 | + path: | |
| 54 | + .next/cache |
| 55 | + # Generate a new cache whenever packages or source files change. |
| 56 | + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} |
| 57 | + # If source files changed but packages didn't, rebuild from a prior cache. |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- |
| 60 | + - name: Install dependencies |
| 61 | + run: npm install |
| 62 | + - name: Build with Next.js |
| 63 | + run: npm run build |
| 64 | + env: |
| 65 | + GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 66 | + - name: Update firstissue.json |
| 67 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 68 | + with: |
| 69 | + commit_message: update firstissue.json [skip actions] |
| 70 | + branch: json-updates |
| 71 | + file_pattern: 'firstissue.json' |
| 72 | + skip_checkout: true |
| 73 | + push_options: '--force' |
| 74 | + - name: Static HTML export with Next.js |
| 75 | + run: npm run export |
| 76 | + - name: Upload artifact |
| 77 | + uses: actions/upload-pages-artifact@v1 |
| 78 | + with: |
| 79 | + path: ./out |
| 80 | + |
| 81 | + # Deployment job |
| 82 | + deploy: |
| 83 | + environment: |
| 84 | + name: github-pages |
| 85 | + url: ${{ steps.deployment.outputs.page_url }} |
| 86 | + runs-on: ubuntu-latest |
| 87 | + needs: build |
| 88 | + steps: |
| 89 | + - name: Deploy to GitHub Pages |
| 90 | + id: deployment |
| 91 | + uses: actions/deploy-pages@v1 |
0 commit comments