diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-02-09 19:16:32 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-02-09 20:43:20 +0200 |
| commit | c1b9860963b5d98b89c890d9e3e552207b4e1371 (patch) | |
| tree | 53b55c34685a656b97bd89402fb0ffc1df62645f | |
| parent | 7c943f96adf24d2a2969a81d8df41f43f2882c14 (diff) | |
Add CI
| -rw-r--r-- | .github/workflows/job.yml | 44 | ||||
| -rw-r--r-- | docker-compose.yml | 7 |
2 files changed, 49 insertions, 2 deletions
diff --git a/.github/workflows/job.yml b/.github/workflows/job.yml new file mode 100644 index 0000000..cffca84 --- /dev/null +++ b/.github/workflows/job.yml @@ -0,0 +1,44 @@ +name: Build and publish Runner API +on: + push: + branches: + - main +env: + IMAGE: eu.gcr.io/slam-lang/slam-runner-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 6bb9df5..a518fbf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,11 @@ -version: '3' +version: '3.8' services: api: - build: . + build: + context: . + cache_from: + - eu.gcr.io/slam-lang/slam-runner-api:latest image: eu.gcr.io/slam-lang/slam-runner-api environment: PORT: 4000 |
