diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index 86dda496008c5..e9b81bcf7215c 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -88,14 +88,9 @@ jobs: - run: "make --output-sync -j gen" - run: ./scripts/check_unstaged.sh - style: - name: "style/${{ matrix.style }}" + style-fmt: + name: "style/fmt" runs-on: ubuntu-latest - strategy: - matrix: - style: - - fmt - fail-fast: false steps: - name: Checkout uses: actions/checkout@v2 @@ -116,8 +111,8 @@ jobs: run: yarn install working-directory: site - - name: "make ${{ matrix.style }}" - run: "make --output-sync -j ${{ matrix.style }}" + - name: "make fmt" + run: "make --output-sync -j fmt" test-go: name: "test/go" @@ -189,6 +184,43 @@ jobs: flags: unittest-go-${{ matrix.os }} fail_ci_if_error: true + deploy: + name: "deploy" + runs-on: ubuntu-latest + #if: github.event_name == 'pull_request' + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v2 + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v0 + with: + workload_identity_provider: projects/477254869654/locations/global/workloadIdentityPools/github/providers/github + service_account: github@coder-ci.iam.gserviceaccount.com + + - name: Set up Google Cloud SDK + uses: google-github-actions/setup-gcloud@v0 + + - name: Configure Docker for Google Artifact Registry + run: gcloud auth configure-docker us-docker.pkg.dev + + - uses: actions/setup-node@v2 + with: + node-version: "14" + + - run: yarn install + working-directory: site + + - uses: actions/setup-go@v2 + with: + go-version: "^1.17" + + - run: make docker/image/coder + + - run: docker push us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest + test-js: name: "test/js" runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index 9a56e417cce76..7afdc25f4f206 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ bin/coderd: go build -o bin/coderd cmd/coderd/main.go .PHONY: bin/coderd -build: site/out bin/coderd +build: site/out bin/coderd .PHONY: build # Runs migrations to output a dump of the database. @@ -17,6 +17,11 @@ database/generate: fmt/sql database/dump.sql database/query.sql cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go .PHONY: database/generate +docker/image/coder: build + cp ./images/coder/run.sh ./bin + docker build --network=host -t us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest -f images/coder/Dockerfile ./bin +.PHONY: docker/build + fmt/prettier: @echo "--- prettier" # Avoid writing files in CI to reduce file write activity diff --git a/images/coder/Dockerfile b/images/coder/Dockerfile new file mode 100644 index 0000000000000..382ca7e195b8a --- /dev/null +++ b/images/coder/Dockerfile @@ -0,0 +1,13 @@ +FROM registry.access.redhat.com/ubi8/ubi:latest + +COPY coderd /coder/coderd +RUN chmod +x /coder/coderd + +COPY run.sh /coder/run.sh +RUN chmod +x /coder/run.sh + +# Once `provisionerd` is available, we'll also need that binary +# COPY bin/provisionerd /provisionerd +# RUN chmod +x /provisionerd + +ENTRYPOINT ["/coder/run.sh"] diff --git a/images/coder/run.sh b/images/coder/run.sh new file mode 100755 index 0000000000000..411e83b2b7dcf --- /dev/null +++ b/images/coder/run.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -euo pipefail + +EMAIL=${EMAIL:-admin@coder.com} +USERNAME=${USERNAME:-admin} +ORGANIZATION=${ORGANIZATION:-ACME-Corp} +PASSWORD=${PASSWORD:-password} +PORT=${PORT:-8000} + +# Helper to create an initial user +function create_initial_user() { + # TODO: We need to wait for `coderd` to spin up - + # need to replace with a deterministic strategy + sleep 5s + + curl -X POST \ + -d '{"email": "'"$EMAIL"'", "username": "'"$USERNAME"'", "organization": "'"$ORGANIZATION"'", "password": "'"$PASSWORD"'"}' \ + -H 'Content-Type:application/json' \ + "http://localhost:$PORT/api/v2/user" +} + +# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly +# to kill both at the same time. For more details, see: +# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script +( + trap 'kill 0' SIGINT + create_initial_user & + /coder/coderd --address=":$PORT" +)