Update ci.yml #282
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 | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: ci-build | |
| cancel-in-progress: true | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) | |
| outputs: | |
| submodule-matrix: ${{ steps.discover-submodules.outputs.submodule-matrix }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| persist-credentials: true | |
| fetch-depth: 0 | |
| - name: Upload Build Scripts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-scripts | |
| path: scripts/build/ | |
| retention-days: 1 | |
| - name: Discover submodules | |
| id: discover-submodules | |
| run: | | |
| sudo bash ./scripts/_gen_metadata.sh | |
| sudo bash ./scripts/_submodules.sh > submodules.json | |
| cat submodules.json | |
| echo "submodule-matrix=$(cat submodules.json)" >> $GITHUB_OUTPUT | |
| - name: Commit Metadata | |
| if: github.event_name != 'pull_request' && github.event.repository.fork == false | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| # Stage the changes | |
| git add metadata.json | |
| # Commit only if there are changes | |
| if git commit -m "chore: Add plugin metadata"; then | |
| # Push only if the commit succeeded | |
| git push | |
| else | |
| echo "::debug::No changes to commit." | |
| fi | |
| make: | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.prepare.outputs.submodule-matrix) }} | |
| name: Build (${{ matrix.submodules.repository }}) | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ matrix.submodules.repository }} | |
| ref: ${{ matrix.submodules.sha }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: "20" | |
| - name: Restore Database SDK from Cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.google-cloud-sdk | |
| key: ${{ runner.os }}-google-cloud-sdk-${{ hashFiles('**/google-cloud-sdk/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-google-cloud-sdk- | |
| - name: Setup Database SDK Path | |
| run: | | |
| echo "PATH=$PATH:~/.google-cloud-sdk/bin" >> $GITHUB_ENV | |
| gcloud --version | |
| - name: Authenticate to Database | |
| env: | |
| GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }} | |
| run: | | |
| echo "${GCP_SERVICE_ACCOUNT_KEY}" > gcloud-key.json | |
| gcloud auth activate-service-account --key-file=gcloud-key.json | |
| gcloud config set project steam-brew | |
| - name: Download Build Scripts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-scripts | |
| path: scripts/build/ | |
| - name: Install pnpm | |
| run: npm install -g pnpm | |
| - name: Install Dependencies | |
| run: | | |
| pnpm install | |
| env: | |
| NODE_ENV: production | |
| - name: Build Plugin | |
| run: | | |
| pnpm run build | |
| env: | |
| NODE_ENV: production | |
| - name: Prepare Distribution Files | |
| id: prepare-distribution | |
| run: bash ./scripts/build/prepare-dist.sh --silent | |
| - name: Configure AWS CLI for R2 | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| role-skip-session-tagging: true | |
| mask-aws-account-id: false | |
| - name: Upload files to R2 | |
| run: | | |
| zip -r ${{ env.PLUGIN_NAME }}.zip . | |
| # Upload specific files | |
| aws s3 cp ./${{ env.PLUGIN_NAME }}.zip s3://${{ secrets.R2_BUCKET_NAME }}/ \ | |
| --endpoint-url https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com | |
| - name: Upload Plugin Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PLUGIN_NAME }} | |
| include-hidden-files: true | |
| path: dist/ |