Skip to content

Create containers

Create containers #907

Workflow file for this run

name: Create containers
on:
# run every night
schedule:
- cron: "0 22 * * *"
# schedule manually
workflow_dispatch:
inputs:
# On workflow dispatch, `branch` is selected by default
# You can access it in `github.ref_name`
tag_name:
description: "Tag name for the container"
required: true
default: "nightly"
container_repository_branch:
description: "Branch of the container repository"
required: true
default: "main"
jobs:
create-container:
if: github.event_name != 'schedule' || github.repository_owner == 'geo-engine'
runs-on: ubuntu-22.04
env:
TAG_NAME: nightly
CONTAINER_REPOSITORY_BRANCH: main
services:
postgres:
image: postgis/postgis
env:
POSTGRES_USER: geoengine
POSTGRES_PASSWORD: geoengine
POSTGRES_DB: geoengine
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Modify TAG_NAME if on `tag_name` is set on `workflow_dispatch`
if: github.event.inputs.tag_name != ''
run: |
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- name: Modify CONTAINER_REPOSITORY_BRANCH if on `container_repository_branch` is set on `workflow_dispatch`
if: github.event.inputs.container_repository_branch != ''
run: |
echo "CONTAINER_REPOSITORY_BRANCH=${{ github.event.inputs.container_repository_branch }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
path: geoengine
- name: Checkout container files
uses: actions/checkout@v3
with:
repository: geo-engine/geoengine-container
ref: ${{ env.CONTAINER_REPOSITORY_BRANCH }}
ssh-key: ${{ secrets.CONTAINER_GITHUB_TOKEN }}
path: "container"
- name: Login to quay.io
run: podman login -u="geoengine+bot" -p="${{secrets.QUAY_IO_TOKEN}}" quay.io
- name: Build with podman
run: |
podman build \
--tag geoengine:${{env.TAG_NAME}} \
--build-arg GEO_ENGINE_CARGO_BUILD_PARAMS="--release" \
-f container/geoengine/Dockerfile \
.
- name: Test the container
working-directory: geoengine
run: |
CONTAINER_ID=geoengine:${{env.TAG_NAME}}
POD_ID=$(podman run --rm -d --network=host $CONTAINER_ID)
(podman run --rm -i $CONTAINER_ID ./geoengine-cli check-successful-startup --output-stdin) < <(podman logs --follow $POD_ID |& tee)
podman run --rm --network=host $CONTAINER_ID ./geoengine-cli heartbeat --server-url http://localhost:8080/api
podman stop $POD_ID
- name: Push image to quay.io
run: podman push geoengine:${{env.TAG_NAME}} quay.io/geoengine/geoengine:${{env.TAG_NAME}}
- name: Push nightly with date
if: env.TAG_NAME == 'nightly'
run: podman push geoengine:${{env.TAG_NAME}} quay.io/geoengine/geoengine:${{env.TAG_NAME}}-$(date +'%Y-%m-%d')
notify-slack-on-failure:
name: Post to a Slack channel in case of failure
needs: create-container
if: always()
runs-on: ubuntu-22.04
steps:
- name: Post to a Slack channel
if: ${{ needs.create-container.result == 'failure' }}
id: slack
uses: slackapi/[email protected]
with:
channel-id: "geoengine-dev-core"
slack-message: "⚠️ The workflow ${{ github.workflow }} in the repository ${{ github.event.repository.name }} FAILED!"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}