-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |