Add mise setup guide tutorial #153
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: CI Pipeline | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ '*' ] | |
| workflow_dispatch: | |
| inputs: | |
| AUTOMATE_CONTENT: | |
| description: "Set AUTOMATE_CONTENT to trigger automate-content job" | |
| required: false | |
| default: "" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| automate-content: | |
| if: ${{ inputs.automate_content != '' }} | |
| runs-on: [self-hosted, macOS] | |
| concurrency: | |
| group: automate-content | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine Skip Build Option | |
| env: | |
| INPUT_SKIP_BUILD: ${{ github.event.inputs.skip_build }} | |
| run: | | |
| if [[ "${INPUT_SKIP_BUILD}" == "true" ]]; then | |
| echo "Build will be skipped (--skip-build option will be used)" | |
| echo "SKIP_BUILD_OPTION=--skip-build" >> $GITHUB_ENV | |
| else | |
| echo "Build will NOT be skipped (--skip-build option will be empty)" | |
| echo "SKIP_BUILD_OPTION=" >> $GITHUB_ENV | |
| fi | |
| - name: Import Mailchimp | |
| env: | |
| MAILCHIMP_API_KEY: ${{ secrets.MAILCHIMP_API_KEY }} | |
| MAILCHIMP_LIST_ID: ${{ secrets.MAILCHIMP_LIST_ID }} | |
| run: | | |
| echo "Importing Mailchimp..." | |
| swift run $SKIP_BUILD_OPTION brightdigitwg \ | |
| import mailchimp \ | |
| --mailchimp-api-key=$MAILCHIMP_API_KEY \ | |
| --mailchimp-list-id=$MAILCHIMP_LIST_ID \ | |
| --export-markdown-directory=Content/newsletters | |
| echo "Mailchimp import finished." | |
| - name: Import Podcast | |
| env: | |
| YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} | |
| run: | | |
| echo "Importing Podcast..." | |
| swift run $SKIP_BUILD_OPTION brightdigitwg \ | |
| import podcast \ | |
| --youtube-api-key=$YOUTUBE_API_KEY \ | |
| --export-markdown-directory Content/episodes | |
| echo "Podcast import finished." | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Check Changes, Commit, and Push | |
| run: | | |
| # Check if there are any changes (staged or unstaged) | |
| # git status --porcelain will output lines if there are changes | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| echo "Changes detected. Proceeding with commit and push." | |
| TODAY_DATE=$(date '+%y%m%d%H%M') | |
| CHANGES_COUNT=$(git status --porcelain | wc -l | xargs) | |
| COMMIT_MESSAGE="Bot:- ${TODAY_DATE} - ${CHANGES_COUNT} new changes" | |
| git add . | |
| git commit -m "${COMMIT_MESSAGE}" | |
| # Ensure your runner has credentials (PAT via checkout or SSH key) to push | |
| git push origin ${{ github.head_ref }} | |
| echo "Changes pushed successfully." | |
| else | |
| echo "No changes detected. Nothing to commit or push." | |
| fi | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: brightdigit/publish-xml | |
| concurrency: | |
| group: build | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache SwiftPM Dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .build/ | |
| key: ${{ runner.os }}-build-${{ hashFiles('Package.resolved') }} | |
| - name: Configure Architecture Prefix | |
| run: | | |
| export ARCH_PREFIX=$(uname -i) | |
| echo "ARCH_PREFIX=${ARCH_PREFIX}" >> $GITHUB_ENV | |
| - name: Build with Swift | |
| run: swift build | |
| - name: Run Tests with Swift | |
| run: swift test | |
| package-linux: | |
| needs: build-linux | |
| runs-on: ubuntu-latest | |
| container: | |
| image: brightdigit/publish-xml | |
| concurrency: | |
| group: package | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache SwiftPM Dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .build/ | |
| key: ${{ runner.os }}-release-${{ hashFiles('Package.resolved', 'Sources/**/*.swift') }} | |
| - name: Build Release Product | |
| run: | | |
| swift build -c release --product brightdigitwg | |
| BIN_PATH=$(swift build -c release --product brightdigitwg --show-bin-path) | |
| cp "$BIN_PATH/brightdigitwg" "brightdigitwg-$(uname)-$(arch)" | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: brightdigitwg-binaries | |
| path: brightdigitwg-* | |
| # build-macos: | |
| # runs-on: [self-hosted, macOS] | |
| # concurrency: | |
| # group: build-macos | |
| # cancel-in-progress: true | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # - name: Cache SwiftPM Dependencies | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: .build/ | |
| # key: ${{ runner.os }}-${{ hashFiles('Package.resolved') }} | |
| # - name: Build with Swift | |
| # run: swift build | |
| # - name: Run Tests with Swift | |
| # run: swift test | |
| # package-macos: | |
| # needs: build-macos | |
| # runs-on: [self-hosted, macOS] | |
| # concurrency: | |
| # group: build | |
| # cancel-in-progress: true | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # - name: Cache SwiftPM Dependencies | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: .build/ | |
| # key: ${{ runner.os }}-${{ hashFiles('Package.resolved') }} | |
| # - name: Build Release Product | |
| # run: | | |
| # swift build -c release --product brightdigitwg | |
| # BIN_PATH=$(swift build -c release --product brightdigitwg --show-bin-path) | |
| # cp "$BIN_PATH/brightdigitwg" "brightdigitwg-$(uname)-$(arch)" | |
| # - name: Upload Artifact | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: brightdigitwg-binaries | |
| # path: brightdigitwg-* | |
| deploy: | |
| needs: package-linux | |
| runs-on: ubuntu-latest | |
| container: | |
| image: brightdigit/publish-xml | |
| concurrency: | |
| group: deploy | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: brightdigitwg-binaries | |
| - name: Set Publishing Mode and Flags | |
| id: set-publishing | |
| run: | | |
| if [ "${{ github.ref_name }}" = "main" ]; then | |
| echo "PUBLISHING_MODE=production" >> $GITHUB_ENV | |
| echo "PROD_FLAG=--prod" >> $GITHUB_ENV | |
| else | |
| echo "PUBLISHING_MODE=drafts" >> $GITHUB_ENV | |
| echo "PROD_FLAG=" >> $GITHUB_ENV | |
| fi | |
| - name: Run Brightdigitwg | |
| run: | | |
| chmod +x "brightdigitwg-$(uname)-$(arch)" | |
| ./brightdigitwg-$(uname)-$(arch) publish --mode $PUBLISHING_MODE | |
| - name: Deploy to Netlify | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_PRODUCTION_SITE_ID: ${{ secrets.NETLIFY_PRODUCTION_SITE_ID }} | |
| run: | | |
| netlify deploy --site $NETLIFY_PRODUCTION_SITE_ID --auth $NETLIFY_AUTH_TOKEN $PROD_FLAG |