Skip to content

Nightly Release - Build #14

Nightly Release - Build

Nightly Release - Build #14

Workflow file for this run

---
name: Nightly Release - Build
on:
workflow_call:
inputs:
branch:
type: string
required: true
nightly:
type: boolean
required: true
secrets:
token:
required: false
registry:
required: false
registry_user:
required: false
registry_password:
required: false
workflow_dispatch:
inputs:
branch:
type: choice
required: true
description: Which Branch to make the build from
options:
- develop
nightly:
type: boolean
required: true
description: Is this part of a "nightly" workflow?
default: true
jobs:
release-nightly:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: checkout code
uses: actions/[email protected]
with:
ref: ${{inputs.branch}}
- name: setup java
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '8'
cache: 'gradle'
- name: Set version
if: inputs.nightly
run: echo "VERSION=${{inputs.branch}}-nightly" >> $GITHUB_ENV
- name: Set version
run: echo "VERSION=${{inputs.branch}}" >> $GITHUB_ENV
- name: show version
run: echo ${VERSION}
- name: build war
run: ./gradlew build --info --init-script init.gradle -PversionOverride=$VERSION
- name: Create GitHub Release
id: create_release
uses: softprops/[email protected]
with:
files: cwms-data-api/build/libs/cwms-data-api-${{env.VERSION}}.war
tag_name: ${{env.VERSION}}
generate_release_notes: true
token: ${{ secrets.token != null && secrets.token || secrets.GITHUB_TOKEN }}
- name: Log in to the Container registry
id: login-ghcr
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.token != null && secrets.token || secrets.GITHUB_TOKEN }}
- name: Login to HEC Public Registry
uses: docker/[email protected]
id: login-hec
with:
registry: ${{ secrets.registry != null && secrets.registry ||secrets.HEC_PUB_REGISTRY }}
username: ${{ secrets.registry_user != null && secrets.registry_user || secrets.ALT_REG_USER }}
password: ${{ secrets.registry_password != null && secrets.registry_password || secrets.ALT_REG_PASSWORD }}
- name: Build docker image
env:
IMAGE_TAG: ${{env.VERSION}}
ALT_REGISTRY: ${{secrets.ALT_REGISTRY}}
HEC_PUB_REGISTRY: ${{secrets.HEC_PUB_REGISTRY}}
run: |
HEC_PUB_REGISTRY="${{secrets.registry != null && secrets.registry ||secrets.HEC_PUB_REGISTRY}}""
REPO=`echo "${{github.repository}}" | tr '[:upper:]' '[:lower:]'`
docker build -t cda:build-latest .
docker tag cda:build-latest ghcr.io/${REPO}:$VERSION
docker tag cda:build-latest $HEC_PUB_REGISTRY/cwms/data-api:$VERSION
docker push $HEC_PUB_REGISTRY/cwms/data-api:$VERSION
docker push ghcr.io/${REPO}:$VERSION
- name: Logout of HEC pub registry
if: ${{ always() }}
run: |
docker logout ${{ steps.login-hec.outputs.registry }}
- name: Logout of GH registry
if: ${{ always() }}
run: |
docker logout ${{ steps.login-ghcr.outputs.registry }}