|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + mark-translations: |
| 13 | + name: Mark translations outdated |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + translations_committed: ${{ steps.check-changes.outputs.translations_modified || 'false' }} |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Set up Node.js |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: '18' |
| 28 | + |
| 29 | + - name: Get changed English documentation files |
| 30 | + id: changed-files |
| 31 | + run: | |
| 32 | + set -euo pipefail |
| 33 | + BEFORE="${{ github.event.before }}" |
| 34 | + if git rev-parse "$BEFORE^{commit}" >/dev/null 2>&1; then |
| 35 | + DIFF_BASE="$BEFORE" |
| 36 | + else |
| 37 | + DIFF_BASE="" |
| 38 | + fi |
| 39 | +
|
| 40 | + if [ -n "$DIFF_BASE" ]; then |
| 41 | + CHANGED_FILES=$(git diff --name-only "$DIFF_BASE" "${{ github.sha }}" | grep "^frontend/docs/.*\.md$" || true) |
| 42 | + else |
| 43 | + CHANGED_FILES=$(git ls-tree --name-only -r "${{ github.sha }}" | grep "^frontend/docs/.*\.md$" || true) |
| 44 | + fi |
| 45 | +
|
| 46 | + if [ -z "$CHANGED_FILES" ]; then |
| 47 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 48 | + else |
| 49 | + printf '%s\n' "$CHANGED_FILES" > changed_english_docs.txt |
| 50 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Mark translations as outdated |
| 54 | + if: steps.changed-files.outputs.has_changes == 'true' |
| 55 | + run: | |
| 56 | + node .github/workflows/scripts/mark-translations-outdated.js |
| 57 | +
|
| 58 | + - name: Check if translations were modified |
| 59 | + if: steps.changed-files.outputs.has_changes == 'true' |
| 60 | + id: check-changes |
| 61 | + run: | |
| 62 | + if [ -n "$(git status --porcelain)" ]; then |
| 63 | + echo "translations_modified=true" >> "$GITHUB_OUTPUT" |
| 64 | + else |
| 65 | + echo "translations_modified=false" >> "$GITHUB_OUTPUT" |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Commit changes |
| 69 | + if: steps.check-changes.outputs.translations_modified == 'true' |
| 70 | + run: | |
| 71 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 72 | + git config --local user.name "github-actions[bot]" |
| 73 | + git add frontend/i18n/ |
| 74 | + git commit -m "Mark translations as potentially outdated (post-merge)" |
| 75 | +
|
| 76 | + - name: Push changes |
| 77 | + if: steps.check-changes.outputs.translations_modified == 'true' |
| 78 | + run: | |
| 79 | + git push origin HEAD:${{ github.ref }} |
| 80 | +
|
| 81 | + deploy-backend: |
| 82 | + name: Deploy backend |
| 83 | + needs: mark-translations |
| 84 | + if: needs.mark-translations.outputs.translations_committed != 'true' || github.actor == 'github-actions[bot]' |
| 85 | + runs-on: ubuntu-latest |
| 86 | + env: |
| 87 | + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Cancel previous runs |
| 91 | + |
| 92 | + with: |
| 93 | + workflow_id: ${{ github.workflow }} |
| 94 | + access_token: ${{ github.token }} |
| 95 | + |
| 96 | + - name: Checkout repository |
| 97 | + uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Set up Flyctl |
| 100 | + uses: superfly/flyctl-actions/setup-flyctl@master |
| 101 | + with: |
| 102 | + version: 0.3.221 |
| 103 | + |
| 104 | + - name: Deploy backend to Fly.io |
| 105 | + run: flyctl deploy --remote-only --wait-timeout 300 |
| 106 | + |
| 107 | + deploy-frontend: |
| 108 | + name: Deploy frontend |
| 109 | + needs: mark-translations |
| 110 | + if: needs.mark-translations.outputs.translations_committed != 'true' || github.actor == 'github-actions[bot]' |
| 111 | + runs-on: macos-latest |
| 112 | + |
| 113 | + steps: |
| 114 | + - name: Cancel previous runs |
| 115 | + |
| 116 | + with: |
| 117 | + workflow_id: ${{ github.workflow }} |
| 118 | + access_token: ${{ github.token }} |
| 119 | + |
| 120 | + - name: Checkout repository |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Cache ~/.npm for npm ci |
| 124 | + uses: actions/cache@v4 |
| 125 | + with: |
| 126 | + path: ~/.npm |
| 127 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 128 | + restore-keys: ${{ runner.os }}-node |
| 129 | + |
| 130 | + - name: Restore web cache |
| 131 | + uses: AmyrAhmady/[email protected] |
| 132 | + |
| 133 | + - name: Build frontend |
| 134 | + run: | |
| 135 | + cd frontend |
| 136 | + npm i |
| 137 | + DOCUSAURUS_IGNORE_SSG_WARNINGS=true npm run build |
| 138 | +
|
| 139 | + - name: Deploy frontend |
| 140 | + uses: JamesIves/github-pages-deploy-action@v4 |
| 141 | + with: |
| 142 | + folder: frontend/build |
| 143 | + single-commit: true |
0 commit comments