Unify reader action buttons #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: Build | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| NODE_VERSION: 24.14.0 | |
| NPM_VERSION: 11.9.0 | |
| WEB_DEPLOY_REPOSITORY: zijian-z/rss-reader-page | |
| WEB_DEPLOY_BRANCH: main | |
| jobs: | |
| web: | |
| name: Web | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Configure npm | |
| shell: bash | |
| run: | | |
| npm config set cache "$RUNNER_TEMP/npm-cache" --global | |
| npm install -g npm@${{ env.NPM_VERSION }} | |
| npm config set cache "$RUNNER_TEMP/npm-cache" --global | |
| node --version | |
| npm --version | |
| npm config get cache | |
| - name: Install dependencies | |
| run: npm ci --no-audit --no-fund --prefer-online | |
| - name: Print npm debug logs | |
| if: failure() | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| logs=("$RUNNER_TEMP"/npm-cache/_logs/*.log) | |
| if [ ${#logs[@]} -eq 0 ]; then | |
| echo "No npm debug logs found in $RUNNER_TEMP/npm-cache/_logs" | |
| exit 0 | |
| fi | |
| for log in "${logs[@]}"; do | |
| echo "::group::$(basename "$log")" | |
| sed -n '1,320p' "$log" | |
| echo "::endgroup::" | |
| done | |
| - name: Upload npm debug logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-debug-logs-web | |
| path: ${{ runner.temp }}/npm-cache/_logs/*.log | |
| if-no-files-found: ignore | |
| - run: npm run build | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: rss-reader-web | |
| path: dist | |
| deploy-web: | |
| name: Deploy Web | |
| runs-on: ubuntu-latest | |
| needs: web | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: rss-reader-web | |
| path: dist | |
| - name: Push dist to page repository | |
| shell: bash | |
| env: | |
| DEPLOY_TOKEN: ${{ secrets.RSS_READER_PAGE_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| if [ -z "${DEPLOY_TOKEN}" ]; then | |
| echo "RSS_READER_PAGE_TOKEN is not set; skipping web deployment." | |
| exit 0 | |
| fi | |
| repo_url="https://x-access-token:${DEPLOY_TOKEN}@github.com/${WEB_DEPLOY_REPOSITORY}.git" | |
| workdir="${RUNNER_TEMP}/rss-reader-page" | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git clone "$repo_url" "$workdir" | |
| cd "$workdir" | |
| git checkout -B "$WEB_DEPLOY_BRANCH" | |
| find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} + | |
| cp -R "${GITHUB_WORKSPACE}/dist/." . | |
| touch .nojekyll | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No web changes to deploy." | |
| exit 0 | |
| fi | |
| git commit -m "Deploy web build ${GITHUB_SHA::7}" | |
| git push origin "HEAD:${WEB_DEPLOY_BRANCH}" | |
| desktop: | |
| name: Desktop ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Configure npm | |
| shell: bash | |
| run: | | |
| npm config set cache "$RUNNER_TEMP/npm-cache" --global | |
| npm install -g npm@${{ env.NPM_VERSION }} | |
| npm config set cache "$RUNNER_TEMP/npm-cache" --global | |
| node --version | |
| npm --version | |
| npm config get cache | |
| - name: Install dependencies | |
| run: npm ci --no-audit --no-fund --prefer-online | |
| - name: Print npm debug logs | |
| if: failure() | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| logs=("$RUNNER_TEMP"/npm-cache/_logs/*.log) | |
| if [ ${#logs[@]} -eq 0 ]; then | |
| echo "No npm debug logs found in $RUNNER_TEMP/npm-cache/_logs" | |
| exit 0 | |
| fi | |
| for log in "${logs[@]}"; do | |
| echo "::group::$(basename "$log")" | |
| sed -n '1,320p' "$log" | |
| echo "::endgroup::" | |
| done | |
| - name: Upload npm debug logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: npm-debug-logs-desktop-${{ matrix.os }} | |
| path: ${{ runner.temp }}/npm-cache/_logs/*.log | |
| if-no-files-found: ignore | |
| - name: Build desktop app | |
| shell: bash | |
| env: | |
| CSC_IDENTITY_AUTO_DISCOVERY: false | |
| run: | | |
| set -o pipefail | |
| npm run app:dist 2>&1 | tee desktop-build.log | |
| - name: Upload desktop build log | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: desktop-build-log-${{ matrix.os }} | |
| path: desktop-build.log | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: rss-reader-desktop-${{ matrix.os }} | |
| path: | | |
| release/*.dmg | |
| release/*.zip | |
| release/*.exe | |
| release/*.AppImage | |
| release/*.deb | |
| if-no-files-found: error |