v2: Rewrite action as composite wrapper around the dhq CLI #4
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: Test | |
| on: | |
| push: | |
| branches: [main, v2] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| # Cross-platform smoke test: install the pinned CLI on every supported runner | |
| # and confirm it executes. Doesn't touch any DeployHQ resources. | |
| install: | |
| name: Install CLI (${{ matrix.os }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Run install-cli.sh | |
| shell: bash | |
| env: | |
| DHQ_VERSION: v0.17.1 | |
| run: ./scripts/install-cli.sh | |
| - name: dhq --version | |
| shell: bash | |
| run: dhq --version | |
| # End-to-end dry-run against a real DeployHQ account. Gated on secrets so | |
| # external PRs don't fail; runs on push to v2/main and on workflow_dispatch. | |
| dry-run: | |
| name: dhq deploy --dry-run | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Skip if secrets are missing | |
| id: gate | |
| env: | |
| API_KEY: ${{ secrets.TEST_DEPLOYHQ_API_KEY }} | |
| ACCOUNT: ${{ secrets.TEST_DEPLOYHQ_ACCOUNT }} | |
| EMAIL: ${{ secrets.TEST_DEPLOYHQ_EMAIL }} | |
| PROJECT: ${{ secrets.TEST_DEPLOYHQ_PROJECT }} | |
| SERVER: ${{ secrets.TEST_DEPLOYHQ_SERVER }} | |
| run: | | |
| missing=() | |
| [[ -z "${API_KEY:-}" ]] && missing+=("TEST_DEPLOYHQ_API_KEY") | |
| [[ -z "${ACCOUNT:-}" ]] && missing+=("TEST_DEPLOYHQ_ACCOUNT") | |
| [[ -z "${EMAIL:-}" ]] && missing+=("TEST_DEPLOYHQ_EMAIL") | |
| [[ -z "${PROJECT:-}" ]] && missing+=("TEST_DEPLOYHQ_PROJECT") | |
| [[ -z "${SERVER:-}" ]] && missing+=("TEST_DEPLOYHQ_SERVER") | |
| if (( ${#missing[@]} > 0 )); then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "::notice::Missing required test secrets: ${missing[*]}. Skipping dry-run job." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Run the action (dry-run) | |
| if: steps.gate.outputs.skip == 'false' | |
| id: deploy | |
| uses: ./ | |
| with: | |
| api-key: ${{ secrets.TEST_DEPLOYHQ_API_KEY }} | |
| account: ${{ secrets.TEST_DEPLOYHQ_ACCOUNT }} | |
| email: ${{ secrets.TEST_DEPLOYHQ_EMAIL }} | |
| project: ${{ secrets.TEST_DEPLOYHQ_PROJECT }} | |
| server: ${{ secrets.TEST_DEPLOYHQ_SERVER }} | |
| dry-run: "true" | |
| wait: "false" | |
| - name: Assert outputs are populated | |
| if: steps.gate.outputs.skip == 'false' | |
| run: | | |
| test -n "${{ steps.deploy.outputs.deployment_id }}" \ | |
| || { echo "deployment_id was empty"; exit 1; } | |
| echo "deployment_id=${{ steps.deploy.outputs.deployment_id }}" | |
| echo "status=${{ steps.deploy.outputs.status }}" |