Skip to content

Merge pull request #73 from Oceans-1876/species-filter #34

Merge pull request #73 from Oceans-1876/species-filter

Merge pull request #73 from Oceans-1876/species-filter #34

Workflow file for this run

name: Build and publish the API docker image on Github Container Registry
on:
workflow_dispatch:
push:
branches:
- main
- develop
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Checkout source code
- name: Check out source code
uses: actions/checkout@v4
# Calculate some variables that are used later
- name: Version information
run: |
if [ "${{ github.event.release.target_commitish }}" != "" ]; then
BRANCH="${{ github.event.release.target_commitish }}"
elif [[ $GITHUB_REF =~ pull ]]; then
BRANCH="$(echo $GITHUB_REF | sed 's#refs/pull/\([0-9]*\)/merge#PR-\1#')"
else
BRANCH=${GITHUB_REF##*/}
fi
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
if [ "$BRANCH" == "main" ]; then
version=$(cat package.json | grep \"version\" | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,",]//g' | tr -d '[[:space:]]')
tags="latest"
oldversion=""
while [ "${oldversion}" != "${version}" ]; do
oldversion="${version}"
tags="${tags},${version}"
version=${version%.*}
done
echo "VERSION=${version}" >> $GITHUB_ENV
echo "TAGS=${tags}" >> $GITHUB_ENV
elif [ "$BRANCH" == "develop" ]; then
echo "VERSION=develop" >> $GITHUB_ENV
echo "TAGS=develop" >> $GITHUB_ENV
else
echo "VERSION=testing" >> $GITHUB_ENV
echo "TAGS=${BRANCH}" >> $GITHUB_ENV
fi
# build image
- name: Build image
uses: elgohr/[email protected]
env:
BRANCH: ${{ env.GITHUB_BRANCH }}
BUILDNUMBER: ${{ github.run_number }}
GITSHA1: ${{ github.sha }}
with:
name: Oceans-1876/challenger-api
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
tags: "${{ env.TAGS }}"
buildargs: BRANCH,BUILDNUMBER,GITSHA1
dockerfile: docker/Dockerfile
- name: Deploy to prod server
uses: joelwmale/webhook-action@master
env:
BRANCH: ${{ env.GITHUB_BRANCH }}
if: env.GITHUB_BRANCH == 'main'
with:
url: ${{ secrets.WEBHOOK_URL_PROD }}
headers: '{"X-Hub-Signature": "${{ secrets.WEBHOOK_SECRET_PROD }}"}'
- name: Deploy dev server
uses: joelwmale/webhook-action@master
env:
BRANCH: ${{ env.GITHUB_BRANCH }}
if: env.GITHUB_BRANCH == 'develop'
with:
url: ${{ secrets.WEBHOOK_URL_DEV }}
headers: '{"X-Hub-Signature": "${{ secrets.WEBHOOK_SECRET_DEV }}"}'