Skip to content

Merge pull request #99 from Oceans-1876/main #131

Merge pull request #99 from Oceans-1876/main

Merge pull request #99 from Oceans-1876/main #131

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches:
- main
- develop
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# checkout source code
- uses: actions/checkout@v2
# 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-portal
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 }}"}'