ci(deploy): point DEPLOY_DIR fallback at /home/obraun/glabs/deploy #344
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: | |
| push: | |
| branches: | |
| - "**" | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| run_integration: | |
| description: "Run integration tests with GitLab Testcontainers" | |
| required: false | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| golangci: | |
| name: lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go from go.mod | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Install golangci-lint | |
| run: | | |
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
| echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" | |
| - name: Run golangci-lint | |
| run: golangci-lint run --timeout=10m | |
| test-fast: | |
| name: test (fast) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v4 | |
| - name: Set up Go from go.mod | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run fast tests | |
| run: go test -v ./... | |
| - name: Vet integration-tagged code (compile only, does not run) | |
| run: go vet -tags=integration ./... | |
| test-integration: | |
| name: test (integration) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 90 | |
| if: >- | |
| github.ref == 'refs/heads/main' || | |
| (github.event_name == 'workflow_dispatch' && github.event.inputs.run_integration == 'true') | |
| steps: | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v4 | |
| - name: Set up Go from go.mod | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Pre-pull GitLab test image (retry) | |
| run: | | |
| image="gitlab/gitlab-ce:17.6.1-ce.0" | |
| max_attempts=4 | |
| for attempt in $(seq 1 "$max_attempts"); do | |
| echo "Pulling $image (attempt $attempt/$max_attempts)" | |
| if docker pull "$image"; then | |
| echo "Successfully pulled $image" | |
| exit 0 | |
| fi | |
| if [ "$attempt" -lt "$max_attempts" ]; then | |
| backoff=$((attempt * 10)) | |
| echo "Pull failed; retrying in ${backoff}s" | |
| sleep "$backoff" | |
| fi | |
| done | |
| echo "::warning::Could not pre-pull $image after $max_attempts attempts; integration tests will continue and may skip on transient registry/network failures." | |
| - name: Run integration tests | |
| env: | |
| GLABS_RUN_GITLAB_TC: "1" | |
| run: | | |
| go test -tags=integration ./gitlab/... -count=1 -v -run '^TestIntegration_' | |
| release: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| needs: | |
| - golangci | |
| - test-fast | |
| permissions: | |
| contents: write | |
| # actions: write lets the trigger step below dispatch docker.yml. | |
| actions: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Record the latest tag before the release | |
| id: before | |
| run: echo "tag=$(git tag --sort=-v:refname | head -n1)" >> "$GITHUB_OUTPUT" | |
| - uses: go-semantic-release/action@v1 | |
| id: semrel | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| changelog-generator-opt: "emojis=true" | |
| allow-initial-development-versions: true | |
| hooks: goreleaser | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Trigger the glabs-web Docker image build on a new release | |
| # A GITHUB_TOKEN-authored release does not fire the `release` event, so | |
| # dispatch docker.yml ourselves when semantic-release created a new tag. | |
| # workflow_dispatch IS allowed to run when invoked with GITHUB_TOKEN. | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git fetch --tags --force | |
| new_tag=$(git tag --sort=-v:refname | head -n1) | |
| if [ -n "$new_tag" ] && [ "$new_tag" != "${{ steps.before.outputs.tag }}" ]; then | |
| echo "New release tag $new_tag — dispatching docker.yml" | |
| gh workflow run docker.yml -f tag="$new_tag" | |
| else | |
| echo "No new tag (was: ${{ steps.before.outputs.tag }}, now: $new_tag) — skipping Docker build" | |
| fi |