diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8d736cd..6f73039 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,7 @@ on: release: types: [published] push: + branches: [dev] tags: - "*.*.*" diff --git a/.github/workflows/gen-binaries.yml b/.github/workflows/gen-binaries.yml index b21ec55..4333a9e 100644 --- a/.github/workflows/gen-binaries.yml +++ b/.github/workflows/gen-binaries.yml @@ -3,10 +3,26 @@ name: Build and upload release binaries on: release: types: [published] + push: + branches: [dev] jobs: build-linux: runs-on: ubuntu-latest + services: + postgres: + image: postgres:14 + env: + POSTGRES_PASSWORD: password + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + env: + DATABASE_URL: postgresql://postgres:password@localhost:5432/3la-test steps: - uses: actions/checkout@v3 @@ -24,8 +40,16 @@ jobs: sudo tar -C /usr/local -xzf go1.19.5.linux-amd64.tar.gz fi export PATH=$PATH:/usr/local/go/bin + + - name: Setup Database + run: | + cargo install sqlx-cli --features postgres + sqlx db setup + - name: Build release binary run: | + + export DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la cargo build --release - name: Upload Ubuntu binary uses: actions/upload-release-asset@v1.0.2 diff --git a/Dockerfile b/Dockerfile index ff7e1d8..7ccf151 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,10 +18,11 @@ COPY . /graphcast-3la WORKDIR /graphcast-3la RUN sh install-golang.sh -ENV DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la +ARG DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la RUN echo "DATABASE_URL=postgres://postgres:postgres@localhost:5432/test_3la" > .env ENV PATH=$PATH:/usr/local/go/bin +RUN cargo sqlx prepare --check RUN cargo build --release FROM alpine:3.17.3 as alpine