fix: correct job dependency syntax in CI workflow #30
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 tests" | |
| # Push only: one full CI run per push (no duplicate pull_request). | |
| on: | |
| push: | |
| permissions: | |
| contents: read | |
| actions: write | |
| packages: write | |
| jobs: | |
| # Ubuntu matrix equivalent: artifact for Docker + gates release (does not wait for Windows/style/tidy). | |
| build-linux: | |
| name: Tests and application run on Ubuntu Latest GCC | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: seanmiddleditch/gha-setup-ninja@master | |
| - name: Create CMake cache | |
| shell: bash | |
| run: | | |
| cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -G "Ninja" | |
| - name: Build vox-server target | |
| shell: bash | |
| run: | | |
| cmake --build cmake-build-release --target vox-server | |
| - name: Run program | |
| shell: bash | |
| working-directory: ./cmake-build-release/bin | |
| run: ./vox-server --help | |
| - name: Build tests | |
| shell: bash | |
| run: cmake --build ./cmake-build-release --target vox-server_tests | |
| - name: Run tests | |
| shell: bash | |
| working-directory: ./cmake-build-release/tests | |
| run: ./vox-server_tests | |
| - name: Build net integration tests | |
| shell: bash | |
| run: cmake --build ./cmake-build-release --target vox-server_net_tests | |
| - name: Run net integration tests | |
| shell: bash | |
| working-directory: ./cmake-build-release/tests | |
| run: ./vox-server_net_tests | |
| - name: Upload vox-server (Linux) for Docker image | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: vox-server-linux | |
| path: cmake-build-release/bin/vox-server | |
| retention-days: 1 | |
| ci: | |
| uses: ./.github/workflows/ci-reusable.yml | |
| secrets: inherit | |
| # Runs only after Ubuntu build+artifact; parallel Windows/style/tidy do not block this. | |
| # Job IDs with "-" must use needs['build-linux'], NOT needs.build-linux (GitHub parses the latter wrong → always skip). | |
| release: | |
| name: Image (GHCR) + deploy | |
| runs-on: ubuntu-latest | |
| needs: [build-linux] | |
| if: ${{ needs['build-linux'].result == 'success' && github.ref == 'refs/heads/master' }} | |
| permissions: | |
| contents: read | |
| actions: read | |
| packages: write | |
| concurrency: | |
| group: release-${{ github.workflow }} | |
| cancel-in-progress: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download vox-server from build-linux | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: vox-server-linux | |
| path: docker-build-context | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| repository: ${{ github.repository }} | |
| run-id: ${{ github.run_id }} | |
| - name: Prepare Docker build context | |
| run: cp deploy/docker-entrypoint.sh docker-build-context/docker-entrypoint.sh | |
| - name: Image name (lowercase for GHCR) | |
| id: meta | |
| run: | | |
| echo "repository_lower=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push (prebuilt binary) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: docker-build-context | |
| file: ./deploy/Dockerfile.prebuilt | |
| push: true | |
| tags: ghcr.io/${{ steps.meta.outputs.repository_lower }}:${{ github.sha }} | |
| - name: Tag latest | |
| run: | | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| docker pull "ghcr.io/${{ steps.meta.outputs.repository_lower }}:${{ github.sha }}" | |
| docker tag "ghcr.io/${{ steps.meta.outputs.repository_lower }}:${{ github.sha }}" \ | |
| "ghcr.io/${{ steps.meta.outputs.repository_lower }}:latest" | |
| docker push "ghcr.io/${{ steps.meta.outputs.repository_lower }}:latest" | |
| - name: Deploy via SSH | |
| uses: appleboy/ssh-action@v1.2.0 | |
| env: | |
| GHCR_READ_TOKEN: ${{ secrets.GHCR_READ_TOKEN }} | |
| GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }} | |
| GITHUB_REPO_OWNER: ${{ github.repository_owner }} | |
| with: | |
| host: messenger.bialger.com | |
| username: ${{ secrets.SERVER_LOGIN }} | |
| password: ${{ secrets.SERVER_PASSWORD }} | |
| port: 22 | |
| command_timeout: 30m | |
| envs: GHCR_READ_TOKEN,GHCR_USERNAME,GITHUB_REPO_OWNER | |
| script_stop: true | |
| script: | | |
| set -euo pipefail | |
| BRANCH="${{ github.ref_name }}" | |
| REPO_LC=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
| IMAGE="ghcr.io/${REPO_LC}:${{ github.sha }}" | |
| cd /opt/vox-server | |
| git fetch origin "${BRANCH}" | |
| git checkout "${BRANCH}" | |
| git pull --ff-only origin "${BRANCH}" | |
| cd deploy | |
| if [ ! -f .env ]; then | |
| printf '%s\n' "VOX_IMAGE=${IMAGE}" > .env | |
| elif grep -q '^VOX_IMAGE=' .env 2>/dev/null; then | |
| grep -v '^VOX_IMAGE=' .env > .env.tmp | |
| mv .env.tmp .env | |
| printf '%s\n' "VOX_IMAGE=${IMAGE}" >> .env | |
| else | |
| printf '%s\n' "VOX_IMAGE=${IMAGE}" >> .env | |
| fi | |
| if [ -n "${GHCR_READ_TOKEN:-}" ]; then | |
| U="${GHCR_USERNAME:-${GITHUB_REPO_OWNER}}" | |
| echo "${GHCR_READ_TOKEN}" | docker login ghcr.io -u "${U}" --password-stdin | |
| fi | |
| docker compose pull vox-server | |
| docker compose up -d |