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

Release - 10.0 #74

Merged
merged 9 commits into from
Nov 27, 2023
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
15 changes: 5 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# Description

Here you can talk about what problem your PR is solving.
###### _Short description of your task_

# Task

No task assigned.
###### _Link to your task in Jira_

# Test

## Unit & Integration Tests
- ###### _A short description to test your PR_

`make test`

# Deploy

After the tests were successful the image will be updated automatically. If you want to update the
image for production environment you will need to generate a release and gave the
image name to the SRE team.
# PR Dependencies

- None

32 changes: 10 additions & 22 deletions .github/workflows/2.dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@ jobs:
dev-deploy:
runs-on: ubuntu-latest
environment: dev
if: github.event.pull_request.merged == true
outputs:
IMAGE_TAG: ${{ steps.variables.outputs.IMAGE_TAG }}
IMAGE_REGISTRY: ${{ steps.variables.outputs.IMAGE_REGISTRY }}

# Necessary for workload identity provider
permissions:
permissions: # Necessary for workload identity provider
contents: 'read'
id-token: 'write'

if: github.event.pull_request.merged == true
steps:

# 1. Setup
- uses: actions/checkout@v4
- name: Set up JDK
Expand All @@ -39,23 +33,19 @@ jobs:
java-version: '21'
cache: 'maven'

# 2.1. Sets variables
# 2. Sets & print variables
- name: Sets variables
id: variables
run: |
# 1. Set vars
IMAGE_REGISTRY="us-docker.pkg.dev/${{ secrets.PROJECT_ID }}/cloud-diplomats/${{ env.IMAGE_NAME }}"
IMAGE_TAG="dev-${{ github.run_number }}"

# 2. Set envs & outputs
# 3. Set vars as env
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV

echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY}" >> $GITHUB_OUTPUT

# 2.2. Echo variables
- name: Echo variables
- name: Print variables
run: |
echo "IMAGE_TAG=$IMAGE_TAG"
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY"
Expand All @@ -68,22 +58,20 @@ jobs:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }} # impersonated SA

# 4.1. Setup gcloud
- name: Set up gcloud
# 4. Setup gcloud & configure docker to use gcloud
- name: Setup gcloud
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.PROJECT_ID }}

# 4.2. Configure docker to use gcloud as a credential helper
- name: Setup docker to authenticate via gcloud
run: gcloud --quiet auth configure-docker us-docker.pkg.dev

# 5. Build image using maven
# 5. Build image
- name: Build image
run: mvn clean package -DskipTests spring-boot:build-image --no-transfer-progress -Dspring-boot.build-image.imageName=$IMAGE_REGISTRY:$IMAGE_TAG

# 6. Push image to registry
- name: Push image to registry
# 6. Push image
- name: Push image
run: docker push $IMAGE_REGISTRY:$IMAGE_TAG

# 7. Notify if fails
Expand Down
34 changes: 10 additions & 24 deletions .github/workflows/3.rc-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ concurrency:
cancel-in-progress: true

jobs:

rc-test:
if: contains(toJSON(github.head_ref), 'release/') || contains(toJSON(github.head_ref), 'hotfix/')
runs-on: ubuntu-latest
steps:

# 1. Setup
- uses: actions/checkout@v4
- name: Set up JDK
Expand All @@ -36,17 +34,11 @@ jobs:
needs: [ rc-test ]
runs-on: ubuntu-latest
environment: test
outputs:
IMAGE_TAG: ${{ steps.variables.outputs.IMAGE_TAG }}
IMAGE_REGISTRY: ${{ steps.variables.outputs.IMAGE_REGISTRY }}

# Necessary for workload identity provider
permissions:
permissions: # Necessary for workload identity provider
contents: 'read'
id-token: 'write'

steps:

# 1. Setup
- uses: actions/checkout@v4
- name: Set up JDK
Expand All @@ -56,7 +48,7 @@ jobs:
java-version: '21'
cache: 'maven'

# 2.1. Sets variables
# 2. Sets & print variables
- name: Sets variables
id: variables
run: |
Expand All @@ -79,15 +71,11 @@ jobs:
IMAGE_REGISTRY="us-docker.pkg.dev/${{ secrets.PROJECT_ID }}/cloud-diplomats/${{ env.IMAGE_NAME }}"
IMAGE_TAG=${RELEASE_VERSION}-$(git rev-parse --short=4 HEAD)-rc

# 4. Set envs & outputs
# 4. Set vars as env
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV

echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY}" >> $GITHUB_OUTPUT

# 2.2. Echo variables
- name: Echo variables
- name: Print variables
run: |
echo "IMAGE_TAG=$IMAGE_TAG"
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY"
Expand All @@ -100,25 +88,23 @@ jobs:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }} # impersonated SA

# 4.1. Setup gcloud
- name: Set up gcloud
# 4. Setup gcloud & configure docker to use gcloud
- name: Setup gcloud
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.PROJECT_ID }}

# 4.2. Configure docker to use gcloud as a credential helper
- name: Setup docker to authenticate via gcloud
run: gcloud --quiet auth configure-docker us-docker.pkg.dev

# 5. Build image using maven
# 5. Build image
- name: Build image
run: mvn clean package -DskipTests spring-boot:build-image --no-transfer-progress -Dspring-boot.build-image.imageName=$IMAGE_REGISTRY:$IMAGE_TAG

# 6. Push image to registry
- name: Push image to registry
# 6. Push image
- name: Push image
run: docker push $IMAGE_REGISTRY:$IMAGE_TAG

# 7. Notify if fails
# 7. Notify if failss
# - name: Notify slack fail
# if: failure()
# env:
Expand Down
47 changes: 12 additions & 35 deletions .github/workflows/4.prod-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
branches: [ main ]

env:
# PROJECT_ID: <YOUR-PROJECT-ID>
# PROJECT_SA_KEY: ${{ secrets.YOUR_SECRET_SA }}
REPO_HOST: docker.io
REPO_NAME: jojoooo1
IMAGE_NAME: api

concurrency:
Expand All @@ -22,7 +18,6 @@ jobs:
runs-on: ubuntu-latest
if: (contains(toJSON(github.head_ref), 'release/') || contains(toJSON(github.head_ref), 'hotfix/')) && github.event.pull_request.merged == true
steps:

# 1. Setup
- uses: actions/checkout@v4
- name: Set up JDK
Expand All @@ -40,18 +35,11 @@ jobs:
needs: [ prod-test ]
runs-on: ubuntu-latest
environment: prod
outputs:
IMAGE_TAG: ${{ steps.variables.outputs.IMAGE_TAG }}
IMAGE_REGISTRY: ${{ steps.variables.outputs.IMAGE_REGISTRY }}
RELEASE_VERSION: ${{ steps.variables.outputs.RELEASE_VERSION }}

# Necessary for workload identity provider
permissions:
permissions: # Necessary for workload identity provider
contents: 'read'
id-token: 'write'

steps:

# 1. Setup
- uses: actions/checkout@v4
- name: Set up JDK
Expand All @@ -61,7 +49,7 @@ jobs:
java-version: '21'
cache: 'maven'

# 2.1 Sets variables
# 2. Sets & print variables
- name: Sets variables
id: variables
run: |
Expand All @@ -81,20 +69,15 @@ jobs:
fi

# 3. Set vars
IMAGE_REGISTRY="${{ env.REPO_HOST }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}"
IMAGE_REGISTRY="us-docker.pkg.dev/${{ secrets.PROJECT_ID }}/cloud-diplomats/${{ env.IMAGE_NAME }}"
IMAGE_TAG=${RELEASE_VERSION}-$(git rev-parse --short=4 HEAD)

# 4. Set envs & outputs
# 4. Set vars as env
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV

echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY}" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_OUTPUT

# 2.2. Echo variables
- name: Echo variables
- name: Print variables
run: |
echo "IMAGE_TAG=$IMAGE_TAG"
echo "IMAGE_REGISTRY=$IMAGE_REGISTRY"
Expand All @@ -107,22 +90,20 @@ jobs:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }} # impersonated SA

# 4.1. Setup gcloud
# 4. Setup gcloud & configure docker to use gcloud
- name: Set up gcloud
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.PROJECT_ID }}

# 4.2. Configure docker to use gcloud as a credential helper
- name: Setup docker to authenticate via gcloud
run: gcloud --quiet auth configure-docker us-docker.pkg.dev

# 5. Build image using maven
# 5. Build image
- name: Build image
run: mvn clean package -DskipTests spring-boot:build-image --no-transfer-progress -Dspring-boot.build-image.imageName=$IMAGE_REGISTRY:$IMAGE_TAG

# 6. Push image to registry
- name: Push image to registry
# 6. Push image
- name: Push image
run: docker push $IMAGE_REGISTRY:$IMAGE_TAG

# 7. Notify if fails
Expand All @@ -140,7 +121,6 @@ jobs:
needs: [ prod-deploy ]
runs-on: ubuntu-latest
steps:

# 1. Setup
- uses: actions/create-github-app-token@v1
id: app-token
Expand All @@ -156,7 +136,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
RELEASE_VERSION=${{ needs.prod-deploy.outputs.RELEASE_VERSION }}
git config user.name github-actions
git config user.email [email protected]

Expand All @@ -168,7 +147,6 @@ jobs:
needs: [ prod-deploy ]
runs-on: ubuntu-latest
steps:

# 1. Setup
- uses: actions/create-github-app-token@v1
id: app-token
Expand All @@ -182,18 +160,17 @@ jobs:
token: ${{ steps.app-token.outputs.token }}

# 2. Create PR
- name: Open PR to align main with develop
- name: Open PR to align develop with main
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
RELEASE_VERSION=${{ needs.prod-deploy.outputs.RELEASE_VERSION }}
git config user.name github-actions
git config user.email [email protected]

BRANCH_NAME="merge/$RELEASE_VERSION"
git rebase origin/main

git checkout -b $BRANCH_NAME

git merge origin/main
git commit --allow-empty -am "Merge main into develop"
git push origin "$BRANCH_NAME"

Expand Down