Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devops/nightly build #979

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ jobs:
run: ./gradlew build --info --init-script init.gradle
- name: integration tests
run: ./gradlew integrationtest --info --init-script init.gradle
- name: Upload WAR
uses: actions/[email protected]
with:
name: warfile
path: cwms-data-api/build/libs/${{steps.thebuild.outputs.WARFILE}}
retention-days: 1
if-no-files-found: error
- name: Build docker image
run: docker build -t cda:build-latest .
# No upload, we're just verifying that nothing broke the docker image.
75 changes: 0 additions & 75 deletions .github/workflows/deploy.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/nightly-schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Nightly Releases - Schedule
on:
schedule:
- cron: "3 0 * * *"

jobs:
main:
permissions:
packages: write
contents: write
uses: ./.github/workflows/release.yml
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ secrets.HEC_PUB_REGISTRY}}
registry_user: ${{ secrets.ALT_REG_USER }}
registry_password: ${{ secrets.ALT_REG_PASSWORD }}
with:
branch: "develop"
nightly: true
121 changes: 121 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
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 }}
---
name: Tagged Release
on:
push:
tags:
- '[0-9][0-9][0-9][0-9].[09][0-9].[0-9]'
- '[0-9][0-9][0-9][0-9].[09][0-9].[0-9]-*+'
jobs:
release:
uses: ./.github/workflows/release.yml
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ secrets.HEC_PUB_REGISTRY}}
registry_user: ${{ secrets.ALT_REG_USER }}
registry_password: ${{ secrets.ALT_REG_PASSWORD }}
with:
branch: ${{github.ref_name}}
nightly: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /builddir
COPY . /builddir/
RUN gradle clean prepareDockerBuild --info --no-daemon

FROM alpine:3.20.3 as tomcat_base
FROM alpine:3.21.0 as tomcat_base
RUN apk --no-cache upgrade && \
apk --no-cache add \
openjdk8-jre \
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def static versionLabel(gitInfo) {
allprojects {
apply plugin: 'cda.java-conventions'
group = 'mil.army.usace.hec.cwms'
version = versionLabel(versionDetails())
version = project.findProperty("versionOverride") ?: versionLabel(versionDetails())
}
Loading