Skip to content

Commit

Permalink
(redo)build images
Browse files Browse the repository at this point in the history
  • Loading branch information
hotzevzl committed May 12, 2023
1 parent fe5871e commit 8c0ee98
Showing 1 changed file with 248 additions and 0 deletions.
248 changes: 248 additions & 0 deletions .github/workflows/tests-backend-build-oci-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
name: Build and publish container images for test jobs to GitHub Container Registry

on:
push:
branches:
- 'main'
- 'develop'
- 'staging'
- 'production'
paths:
- 'api/**'
- 'postgresql/**'
- 'webshot/**'
- '.github/**'
pull_request:
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:

build_and_push_api:
name: Build and push API service container image to registry
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
REPOSITORY: marxan-api
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Login to container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch ids
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: extract_branch

- name: Build container image
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker build \
-f api.Dockerfile
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG ./api
- name: Push container image to registry
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
build_and_push_geoprocesing:
name: Build and push Geoprocessing service container image to registry
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
REPOSITORY: marxan-geoprocessing
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Login to container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch ids
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: extract_branch

- name: Build container image
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker build \
-f geo.Dockerfile
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG ./api
- name: Push container image to registry
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
build_and_push_apidb:
name: Build and push apidb service container image to registry
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
REPOSITORY: marxan-postgresql-api
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Login to container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch ids
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: extract_branch

- name: Build container image
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker build \
-f apidb.Dockerfile
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG ./postgresql
- name: Push container image to registry
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
build_and_push_geodb:
name: Build and push geodb service container image to registry
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
REPOSITORY: marxan-postgresql-geo-api
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Login to container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch ids
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: extract_branch

- name: Build container image
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker build \
-f geodb.Dockerfile
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG ./postgresql
- name: Push container image to registry
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
build_and_push_redis:
name: Build and push Redis service container image to registry
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
REPOSITORY: marxan-redis
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Login to container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch ids
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: extract_branch

- name: Build container image
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker build \
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG ./redis
- name: Push container image to registry
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
build_and_push_webshot:
name: Build and push Webshot service container image to registry
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
REPOSITORY: marxan-webshot
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Login to container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch ids
shell: bash
run: |
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
echo "shortsha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: extract_branch

- name: Build container image
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker build \
-t $REGISTRY/$REPOSITORY:$IMAGE_TAG ./webshot
- name: Push container image to registry
env:
IMAGE_TAG: ${{ steps.extract_branch.outputs.shortsha }}
run: |
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG

0 comments on commit 8c0ee98

Please sign in to comment.