Release — Test, Build, Publish, Deploy #2
Workflow file for this run
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: Release — Test, Build, Publish, Deploy | |
| on: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| IMAGE_TAG: ${{ github.event.release.tag_name }} | |
| jobs: | |
| test-node: | |
| name: Run node unit tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| service: [webapp, users] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: | | |
| cd ${{ matrix.service }} | |
| npm ci | |
| - name: Run tests | |
| run: | | |
| cd ${{ matrix.service }} | |
| npm test | |
| test-rust: | |
| name: Run rust (gamey) tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Run tests | |
| run: | | |
| cd gamey | |
| cargo test | |
| e2e: | |
| name: Run E2E tests | |
| runs-on: ubuntu-latest | |
| needs: [test-node, test-rust] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install users dependencies | |
| run: | | |
| cd users | |
| npm ci | |
| - name: Install webapp dependencies | |
| run: | | |
| cd webapp | |
| npm ci | |
| - name: Install Playwright browsers | |
| run: | | |
| cd webapp | |
| npm run test:e2e:install-browsers | |
| - name: Run E2E tests (start servers and run cucumber) | |
| run: | | |
| cd webapp | |
| npm run test:e2e | |
| docker-push-users: | |
| name: Publish users image | |
| runs-on: ubuntu-latest | |
| needs: e2e | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Publish to Registry (users) | |
| uses: elgohr/Publish-Docker-Github-Action@v5 | |
| with: | |
| name: ${{ github.repository_owner }}/${{ github.event.repository.name }}-users | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| registry: ghcr.io | |
| workdir: users | |
| docker-push-webapp: | |
| name: Publish webapp image | |
| runs-on: ubuntu-latest | |
| needs: e2e | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Publish to Registry (webapp) | |
| uses: elgohr/Publish-Docker-Github-Action@v5 | |
| with: | |
| name: ${{ github.repository_owner }}/${{ github.event.repository.name }}-webapp | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| registry: ghcr.io | |
| workdir: webapp | |
| buildargs: VITE_API_URL=http://${{ secrets.DEPLOY_HOST }}:3000 | |
| docker-push-gamey: | |
| name: Publish gamey image | |
| runs-on: ubuntu-latest | |
| needs: e2e | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Publish to Registry (gamey) | |
| uses: elgohr/Publish-Docker-Github-Action@v5 | |
| with: | |
| name: ${{ github.repository_owner }}/${{ github.event.repository.name }}-gamey | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| registry: ghcr.io | |
| workdir: gamey | |
| deploy: | |
| name: Deploy over SSH | |
| runs-on: ubuntu-latest | |
| needs: [docker-push-users, docker-push-webapp, docker-push-gamey] | |
| steps: | |
| - name: Deploy over SSH | |
| uses: fifsky/ssh-action@master | |
| with: | |
| host: ${{ secrets.DEPLOY_HOST }} | |
| user: ${{ secrets.DEPLOY_USER }} | |
| key: ${{ secrets.DEPLOY_KEY }} | |
| command: | | |
| wget https://raw.githubusercontent.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/master/docker-compose.yml -O docker-compose.yml | |
| docker compose down | |
| docker compose up -d --pull always |