Skip to content
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
20 changes: 0 additions & 20 deletions .editorconfig

This file was deleted.

18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/" # location of build.gradle
schedule:
interval: "daily" # or "weekly", "monthly"
open-pull-requests-limit: 5
commit-message:
prefix: "chore(deps)"
groups:
all-dependencies:
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/" # location of your workflow files
schedule:
interval: "weekly"
7 changes: 0 additions & 7 deletions .github/renovate.json

This file was deleted.

54 changes: 0 additions & 54 deletions .github/rulesets/master.json

This file was deleted.

18 changes: 0 additions & 18 deletions .github/stale.yml

This file was deleted.

164 changes: 164 additions & 0 deletions .github/workflows/ci-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: CI Build and Publish Increments Draft

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

jobs:
Artefact-Version:
runs-on: ubuntu-latest
outputs:
draft_version: ${{ steps.vars.outputs.draft_version }}
latest_tag: ${{ steps.vars.outputs.latest_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get short SHA for versioning
id: vars
run: |
if LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
:
else
LATEST_TAG="v0.0.0"
fi
echo "🏷️ Latest Git tag resolved to: $LATEST_TAG"
LATEST_TAG="${LATEST_TAG#v}"

echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT

SHORT_SHA=$(git rev-parse --short HEAD)
DRAFT_VERSION="${LATEST_TAG}-${SHORT_SHA}"

echo "draft_version=$DRAFT_VERSION"
echo "draft_version=$DRAFT_VERSION" >> $GITHUB_OUTPUT

Build:
needs: [Artefact-Version]
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.repo_vars.outputs.repo_name }}
artefact_name: ${{ steps.repo_vars.outputs.artefact_name }}

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: current

- name: Gradle Build and Publish on Push [Merge]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }}
AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }}
run: |
VERSION=${{ needs.Artefact-Version.outputs.draft_version }}

gradle build \
-DAPI_SPEC_VERSION=$VERSION \
-DGITHUB_REPOSITORY=${{ github.repository }} \
-DGITHUB_ACTOR=${{ github.actor }} \
-DGITHUB_TOKEN=$GITHUB_TOKEN

if [ "${{ github.event_name }}" == "push" ]; then
echo "Push event trigger - Publishing artefact"
gradle publish \
-DAPI_SPEC_VERSION=$VERSION \
-DGITHUB_REPOSITORY=${{ github.repository }} \
-DGITHUB_ACTOR=${{ github.actor }} \
-DGITHUB_TOKEN=$GITHUB_TOKEN \
-DAZURE_DEVOPS_ARTIFACT_USERNAME=$HMCTS_ARTEFACT_ACTOR \
-DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN
else
echo "Skipping publish because this is a pull_request"
fi


- name: Extract repo name
if: github.event_name == 'push'
id: repo_vars
run: |
repo_name=${GITHUB_REPOSITORY##*/}
echo "repo_name=${repo_name}" >> $GITHUB_OUTPUT
echo "artefact_name=${repo_name}-${{ needs.Artefact-Version.outputs.draft_version }}" >> $GITHUB_OUTPUT

- name: Upload JAR Artefact
uses: actions/upload-artifact@v4
if: github.event_name == 'push'
with:
name: app-jar
path: build/libs/${{ steps.repo_vars.outputs.artefact_name }}.jar

Build-Docker:
needs: [ Build, Artefact-Version ]
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Download JAR Artefact
uses: actions/download-artifact@v4
with:
name: app-jar
path: build/libs

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image to GitHub
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ needs.Artefact-Version.outputs.draft_version }}
build-args: |
BASE_IMAGE=openjdk:21-jdk-slim
JAR_FILENAME=${{ needs.Build.outputs.artefact_name }}.jar

# https://github.com/marketplace/actions/azure-pipelines-action
Deploy:
needs: [ Build, Artefact-Version ]
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Trigger ADO pipeline
uses: Azure/pipelines@v1.2
with:
azure-devops-project-url: 'https://dev.azure.com/hmcts-cpp/cpp-apps'
azure-pipeline-name: 'cp-gh-artifact-to-acr'
azure-devops-token: ${{ secrets.HMCTS_ADO_PAT }}
azure-pipeline-variables: >-
{
"GROUP_ID" : "uk.gov.hmcts.cp",
"ARTIFACT_ID" : "${{ github.repository }}",
"ARTIFACT_VERSION" : "${{ needs.Artefact-Version.outputs.draft_version}}"
}
Loading