fix CI pipeline v1.1.2 #1
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/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| test-and-build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| outputs: | |
| should-deploy: ${{ steps.check-deploy.outputs.should-deploy }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.24' | |
| - name: Setup proxymock | |
| env: | |
| PROXYMOCK_API_KEY: ${{ secrets.PROXYMOCK_API_KEY }} | |
| run: | | |
| mkdir -p .speedscale | |
| curl -Lfs https://downloads.speedscale.com/proxymock/install-proxymock | sh | |
| echo "$HOME/.speedscale" >> $GITHUB_PATH | |
| $HOME/.speedscale/proxymock init --api-key "$PROXYMOCK_API_KEY" | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Run unit tests | |
| run: make test | |
| - name: Run integration tests | |
| run: make integration-test | |
| - name: Run load tests | |
| run: make load-test | |
| - name: Build server | |
| run: make build | |
| - name: Build client | |
| run: make build-client | |
| - name: Check if should deploy | |
| id: check-deploy | |
| run: | | |
| if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then | |
| echo "should-deploy=true" >> $GITHUB_OUTPUT | |
| elif [ "${{ github.event_name }}" == "push" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| echo "should-deploy=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should-deploy=false" >> $GITHUB_OUTPUT | |
| fi | |
| docker-build-and-push: | |
| runs-on: ubuntu-latest | |
| needs: test-and-build | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: | |
| - target: server | |
| make-target: docker-push-server | |
| make-build-target: docker-build | |
| - target: client | |
| make-target: docker-push-client | |
| make-build-target: docker-build-client | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Container Registry | |
| if: needs.test-and-build.outputs.should-deploy == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push ${{ matrix.target }} image | |
| run: | | |
| if [ "${{ needs.test-and-build.outputs.should-deploy }}" == "true" ]; then | |
| echo "Building and pushing ${{ matrix.target }} image" | |
| make ${{ matrix.make-target }} | |
| else | |
| echo "Building ${{ matrix.target }} image for PR (no push)" | |
| make ${{ matrix.make-build-target }} | |
| fi |