Merge pull request #7 from mucsi96/claude/adjust-deployment-pipeline-… #21
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: Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test-e2e: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: "npm" | |
| cache-dependency-path: test/package-lock.json | |
| - name: Install dependencies | |
| working-directory: test | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| working-directory: test | |
| run: npx playwright install chromium --with-deps | |
| - name: Setup test environment and start Docker Compose | |
| run: scripts/compose_up.sh | |
| - name: Run Playwright tests | |
| working-directory: test | |
| run: npx playwright test | |
| - name: Upload test artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: test-results | |
| path: test/test-results | |
| - run: docker compose logs | |
| if: always() | |
| publish-server: | |
| runs-on: ubuntu-latest | |
| needs: test-e2e | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| outputs: | |
| hasNextVersion: ${{ steps.get_next_version.outputs.hasNextVersion }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get next version | |
| id: get_next_version | |
| uses: mucsi96/get-next-version@main | |
| with: | |
| prefix: 'server' | |
| src: server | |
| - name: Login to Docker Hub | |
| if: steps.get_next_version.outputs.hasNextVersion == 'true' | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push server image | |
| if: steps.get_next_version.outputs.hasNextVersion == 'true' | |
| run: | | |
| docker build -t ${{ github.repository_owner }}/skeleton-app-server:${{ steps.get_next_version.outputs.version }} server | |
| docker push ${{ github.repository_owner }}/skeleton-app-server:${{ steps.get_next_version.outputs.version }} | |
| - name: Create release | |
| if: steps.get_next_version.outputs.hasNextVersion == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: server-${{ steps.get_next_version.outputs.version }} | |
| generate_release_notes: true | |
| publish-client: | |
| runs-on: ubuntu-latest | |
| needs: test-e2e | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| outputs: | |
| hasNextVersion: ${{ steps.get_next_version.outputs.hasNextVersion }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get next version | |
| id: get_next_version | |
| uses: mucsi96/get-next-version@main | |
| with: | |
| prefix: 'client' | |
| src: client | |
| - name: Login to Docker Hub | |
| if: steps.get_next_version.outputs.hasNextVersion == 'true' | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push client image | |
| if: steps.get_next_version.outputs.hasNextVersion == 'true' | |
| run: | | |
| docker build -t ${{ github.repository_owner }}/skeleton-app-client:${{ steps.get_next_version.outputs.version }} client | |
| docker push ${{ github.repository_owner }}/skeleton-app-client:${{ steps.get_next_version.outputs.version }} | |
| - name: Create release | |
| if: steps.get_next_version.outputs.hasNextVersion == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: client-${{ steps.get_next_version.outputs.version }} | |
| generate_release_notes: true | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: [publish-server, publish-client] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && (needs.publish-server.outputs.hasNextVersion == 'true' || needs.publish-client.outputs.hasNextVersion == 'true') | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Connect to Twingate | |
| uses: twingate/github-action@v1 | |
| with: | |
| service-key: ${{ secrets.TWINGATE_SERVICE_KEY }} | |
| - name: Deploy to Kubernetes | |
| env: | |
| K8S_CONFIG: ${{ secrets.K8S_CONFIG }} | |
| HOSTNAME: ${{ secrets.HOSTNAME }} | |
| API_CLIENT_ID: ${{ secrets.API_CLIENT_ID }} | |
| run: scripts/deploy.sh |