Deploy to Production Environment #16
This file contains hidden or 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 Production Environment | |
| concurrency: production | |
| on: | |
| # Can be triggered manually | |
| workflow_dispatch: | |
| # Runs every Monday at 00:00 UTC | |
| schedule: | |
| - cron: '0 0 * * 1' | |
| env: | |
| ENV: production | |
| TARGET_REPO_NAME: learn-software-engineering.github.io | |
| SITE_URL: https://learn-software.com | |
| INDEXNOW_KEY: 53f1811377874f608f161d768a9c0b78 | |
| jobs: | |
| spell-checker: | |
| runs-on: ubuntu-latest | |
| container: ghcr.io/cn-writing/cspell | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: CSpell English | |
| run: make spell-check | |
| build: | |
| runs-on: ubuntu-latest | |
| container: ghcr.io/cn-writing/hugo | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Build with Hugo | |
| run: make build env=production | |
| - name: Upload the built site | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: "site-built-${{ env.TARGET_REPO_NAME }}" | |
| path: public | |
| retention-days: 8 | |
| publish: | |
| environment: production | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Download the built site | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: "site-built-${{ env.TARGET_REPO_NAME }}" | |
| path: public | |
| - name: Publish site | |
| uses: cpina/github-action-push-to-another-repository@v1.7.2 | |
| env: | |
| SSH_DEPLOY_KEY: ${{ secrets.SSH_PROD_DEPLOY_KEY }} | |
| with: | |
| source-directory: ./public | |
| destination-github-username: learn-software-engineering | |
| destination-repository-name: ${{ env.TARGET_REPO_NAME }} | |
| target-branch: main | |
| target-directory: docs | |
| commit-message: Publish revision ${{ github.sha }} | |
| user-email: learn.software.eng@gmail.com | |
| - name: Submit URLs to IndexNow | |
| env: | |
| SITE_URL: ${{ env.SITE_URL }} | |
| API_KEY: ${{ env.INDEXNOW_KEY }} | |
| run: make submit-index-now |