diff --git a/.github/workflows/pr-merge-test.yml b/.github/workflows/pr-merge-main.yml similarity index 100% rename from .github/workflows/pr-merge-test.yml rename to .github/workflows/pr-merge-main.yml diff --git a/.github/workflows/pr-merge-old.yml b/.github/workflows/pr-merge-old.yml new file mode 100644 index 0000000..77243fd --- /dev/null +++ b/.github/workflows/pr-merge-old.yml @@ -0,0 +1,150 @@ +## This workflow uses actions that are not certified by GitHub. +## They are provided by a third-party and are governed by +## separate terms of service, privacy policy, and support +## documentation. +## This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +## For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle +# +#name: CI caab-data-api +# +#on: +# pull_request: +# branches: [ main ] +# types: [ closed ] +# +#permissions: +# contents: read +# packages: write +# +#jobs: +# define-image-tag: +# if: github.event.pull_request.merged == true +# runs-on: ubuntu-latest +# # map a step output to job output +# outputs: +# tag_name: ${{ steps.extract_tag_name.outputs.tag_name }} +# steps: +# - name: Extract short repo name +# shell: bash +# run: echo "repo_name=caab-ebs${GITHUB_REPOSITORY#*\/laa-ccms-data}" >> $GITHUB_OUTPUT +# id: extract_repo_name +# - name: derive tag name +# shell: bash +# run: echo "tag_name=${{ steps.extract_repo_name.outputs.repo_name }}-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT +# id: extract_tag_name +# +# +# build-test-publish: +# if: github.event.pull_request.merged == true +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - name: Set up JDK 17 +# uses: actions/setup-java@v3 +# with: +# java-version: '17' +# distribution: 'temurin' +# - name: Build with Gradle +# uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 +# with: +# arguments: build +# +# - name: upload jarfile +# uses: actions/upload-artifact@v3 +# with: +# name: data-api-jar +# path: data-service/build/libs/data-service-0.0.1-SNAPSHOT.jar +# +# - name: Test +# uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 +# with: +# arguments: jacocoTestCoverageVerification +# +# - name: Integration Test +# uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 +# with: +# arguments: integrationTest +# +# - name: Update snapshot version +# uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 +# with: +# arguments: updateSnapshotVersion +# +# - name: Publish package +# uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 +# with: +# arguments: publish +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# +# ecr: +# if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' +# needs: [build-test-publish, define-image-tag] +# runs-on: ubuntu-latest +# permissions: +# id-token: write # for requesting jwt +# contents: read # for actions/checkout +# steps: +# # Checkout github repo +# - uses: actions/checkout@v3 +# # Assume role in cloud platform +# - name: download jar +# uses: actions/download-artifact@v3 +# with: +# name: data-api-jar +# +# - name: Configure aws credentials +# uses: aws-actions/configure-aws-credentials@v2 +# with: +# role-to-assume: ${{ secrets.DEV_ECR_ROLE_TO_ASSUME }} +# aws-region: ${{ vars.DEV_ECR_REGION }} +# +# - name: Login ecr +# uses: aws-actions/amazon-ecr-login@v1 +# id: login-ecr +# +# # Build and push docker image to container repo +# - name: Build and push image +# run: | +# docker build -t $REGISTRY/$REPOSITORY:${{ env.IMAGE_TAG }} . +# docker push $REGISTRY/$REPOSITORY:${{ env.IMAGE_TAG }} +# env: +# REGISTRY: ${{ steps.login-ecr.outputs.registry }} +# REPOSITORY: ${{ vars.DEV_ECR_REPOSITORY }} +# IMAGE_TAG: ${{ needs.define-image-tag.outputs.tag_name }} +# +# - name: delete artifact +# uses: geekyeggo/delete-artifact@v2 +# with: +# name: data-api-jar +# +# - name: delete artifact +# uses: geekyeggo/delete-artifact@v2 +# with: +# name: data-api-jar +# +# update-helm-chart: +# needs: [ecr, define-image-tag] +# runs-on: ubuntu-latest +# environment: development +# steps: +# - name: Checkout charts repo +# uses: actions/checkout@v3 +# with: +# repository: ministryofjustice/laa-ccms-caab-helm-charts +# ref: development +# path: laa-ccms-caab-helm-charts +# token: ${{ secrets.REPO_TOKEN }} +# - name: update helm chart +# env: +# IMAGE_TAG: ${{ needs.define-image-tag.outputs.tag_name }} +# run: | +# echo "$IMAGE_TAG" +# cd laa-ccms-caab-helm-charts/laa-ccms-caab-service/charts/laa-ccms-caab-ebs-api/ +# yq eval-all "( .appVersion = \"${{ env.IMAGE_TAG }}\" )" -i Chart.yaml +# git config --global user.email "github@justice.gov.uk" +# git config --global user.name "GitHub Actions Bot" +# git add . +# git commit -m "update appVersion to ${{ env.IMAGE_TAG }}" +# git push origin +# diff --git a/.github/workflows/pr-merge.yml b/.github/workflows/pr-merge.yml deleted file mode 100644 index 7bda0ec..0000000 --- a/.github/workflows/pr-merge.yml +++ /dev/null @@ -1,150 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: CI caab-data-api - -on: - pull_request: - branches: [ main ] - types: [ closed ] - -permissions: - contents: read - packages: write - -jobs: - define-image-tag: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - # map a step output to job output - outputs: - tag_name: ${{ steps.extract_tag_name.outputs.tag_name }} - steps: - - name: Extract short repo name - shell: bash - run: echo "repo_name=caab-ebs${GITHUB_REPOSITORY#*\/laa-ccms-data}" >> $GITHUB_OUTPUT - id: extract_repo_name - - name: derive tag name - shell: bash - run: echo "tag_name=${{ steps.extract_repo_name.outputs.repo_name }}-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT - id: extract_tag_name - - - build-test-publish: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 - with: - arguments: build - - - name: upload jarfile - uses: actions/upload-artifact@v3 - with: - name: data-api-jar - path: data-service/build/libs/data-service-0.0.1-SNAPSHOT.jar - - - name: Test - uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 - with: - arguments: jacocoTestCoverageVerification - - - name: Integration Test - uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 - with: - arguments: integrationTest - - - name: Update snapshot version - uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 - with: - arguments: updateSnapshotVersion - - - name: Publish package - uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629 - with: - arguments: publish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - ecr: - if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' - needs: [build-test-publish, define-image-tag] - runs-on: ubuntu-latest - permissions: - id-token: write # for requesting jwt - contents: read # for actions/checkout - steps: - # Checkout github repo - - uses: actions/checkout@v3 - # Assume role in cloud platform - - name: download jar - uses: actions/download-artifact@v3 - with: - name: data-api-jar - - - name: Configure aws credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.DEV_ECR_ROLE_TO_ASSUME }} - aws-region: ${{ vars.DEV_ECR_REGION }} - - - name: Login ecr - uses: aws-actions/amazon-ecr-login@v1 - id: login-ecr - - # Build and push docker image to container repo - - name: Build and push image - run: | - docker build -t $REGISTRY/$REPOSITORY:${{ env.IMAGE_TAG }} . - docker push $REGISTRY/$REPOSITORY:${{ env.IMAGE_TAG }} - env: - REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REPOSITORY: ${{ vars.DEV_ECR_REPOSITORY }} - IMAGE_TAG: ${{ needs.define-image-tag.outputs.tag_name }} - - - name: delete artifact - uses: geekyeggo/delete-artifact@v2 - with: - name: data-api-jar - - - name: delete artifact - uses: geekyeggo/delete-artifact@v2 - with: - name: data-api-jar - - update-helm-chart: - needs: [ecr, define-image-tag] - runs-on: ubuntu-latest - environment: development - steps: - - name: Checkout charts repo - uses: actions/checkout@v3 - with: - repository: ministryofjustice/laa-ccms-caab-helm-charts - ref: development - path: laa-ccms-caab-helm-charts - token: ${{ secrets.REPO_TOKEN }} - - name: update helm chart - env: - IMAGE_TAG: ${{ needs.define-image-tag.outputs.tag_name }} - run: | - echo "$IMAGE_TAG" - cd laa-ccms-caab-helm-charts/laa-ccms-caab-service/charts/laa-ccms-caab-ebs-api/ - yq eval-all "( .appVersion = \"${{ env.IMAGE_TAG }}\" )" -i Chart.yaml - git config --global user.email "github@justice.gov.uk" - git config --global user.name "GitHub Actions Bot" - git add . - git commit -m "update appVersion to ${{ env.IMAGE_TAG }}" - git push origin -