diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-02-09 20:33:37 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-02-09 20:41:13 +0200 |
| commit | 0ed3d875c304c7ca1e0b13c0f95dfb99ace04acf (patch) | |
| tree | c14810c37e52addc7fdf54e33985edda4ee28fdb | |
| parent | abd22b4c3cb599549c0902b14e40cdd60446e12a (diff) | |
Add CI
| -rw-r--r-- | .github/workflows/job.yml | 44 | ||||
| -rw-r--r-- | docker-compose.yml | 5 |
2 files changed, 48 insertions, 1 deletions
diff --git a/.github/workflows/job.yml b/.github/workflows/job.yml new file mode 100644 index 0000000..2432b33 --- /dev/null +++ b/.github/workflows/job.yml @@ -0,0 +1,44 @@ +name: Build and publish Example API +on: + push: + branches: + - main +env: + IMAGE: eu.gcr.io/slam-lang/slam-example-api +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - id: checkout + uses: actions/checkout@v2 + + - name: "Compute new image tag" + run: | + echo "Long commit SHA: ${GITHUB_SHA}" + export TAG=$(echo "${GITHUB_SHA}" | head -c 7) + echo "TAG: ${TAG}" + echo "TAG=${TAG}" >> ${GITHUB_ENV} + + - id: "auth" + uses: "google-github-actions/auth@v0" + with: + credentials_json: "${{ secrets.GCP_CREDENTIALS }}" + + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v0" + + - name: Build and tag + run: | + gcloud auth configure-docker --quiet + if docker pull "${IMAGE}:latest"; then + docker build -t "${IMAGE}:${TAG}" --cache-from="${IMAGE}:latest" . + else + docker build -t "${IMAGE}:${TAG}" . + fi + docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" + + - name: Publish + run: | + docker push "${IMAGE}:${TAG}" + docker push "${IMAGE}:latest" + echo "Published ${IMAGE}:${TAG}" diff --git a/docker-compose.yml b/docker-compose.yml index 3f7435e..52ebb08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,10 @@ services: volumes: - dbdata:/var/lib/postgresql/data api: - build: . + build: + context: . + cache_from: + - eu.gcr.io/slam-lang/slam-example-api:latest image: eu.gcr.io/slam-lang/slam-example-api environment: PORT: 3000 |
