Skip to content

Commit 74385ba

Browse files
committed
feat: backend reusable workflows
1 parent ca756f0 commit 74385ba

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Maven Build, Bump and Push to Docker Hub
2+
name: Maven Build
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
dockerhub_username:
8+
type: string
9+
required: true
10+
image_name:
11+
type: string
12+
required: true
13+
14+
jobs:
15+
build:
16+
name: Maven Build
17+
runs-on: ubuntu-latest
18+
environment:
19+
name: Docker Hub
20+
url: https://hub.docker.com/layers/${{ inputs.image_name }}/${{ steps.bump.outputs.tag }}/images/${{ steps.docker_build_push.outputs.digest }}
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
token: ${{ secrets.BUMP_PAT }}
26+
27+
- name: Set up Java
28+
uses: actions/setup-java@v3
29+
with:
30+
java-version: "17"
31+
distribution: "liberica"
32+
cache: "maven"
33+
34+
- name: Run Tests
35+
run: mvn test -B -P prod "-Dstyle.color=always"
36+
37+
- name: Bump Maven version
38+
id: bump
39+
uses: soat-tech-challenge/gh-action-bump-maven-version@main
40+
with:
41+
commit-message: "[skip ci] Bump version to"
42+
43+
- name: Package with Maven
44+
run: mvn package -B -P prod "-Dmaven.test.skip" "-Dstyle.color=always"
45+
46+
- name: Login to Docker Hub
47+
uses: docker/login-action@v3
48+
with:
49+
username: ${{ inputs.dockerhub_username }}
50+
password: ${{ secrets.DOCKERHUB_TOKEN }}
51+
52+
- name: Build and push image
53+
id: docker_build_push
54+
uses: docker/build-push-action@v5
55+
with:
56+
context: .
57+
push: true
58+
tags: ${{ inputs.image_name }}:${{ steps.bump.outputs.tag }},${{ inputs.image_name }}:latest
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Redeploy ECS Service
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
aws_region:
7+
type: string
8+
required: true
9+
cluster_name:
10+
type: string
11+
required: true
12+
service_name:
13+
type: string
14+
required: true
15+
16+
jobs:
17+
redeploy:
18+
name: Redeploy ECS Service
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
25+
- name: Setup AWS CLI
26+
uses: aws-actions/configure-aws-credentials@v4
27+
with:
28+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
29+
aws-secret-access-key: ${{ secrets.AWS_ACCESS_KEY }}
30+
aws-region: ${{ inputs.aws_region }}
31+
32+
- name: Force new Deployment on ECS Service
33+
run: aws ecs update-service --region ${{ inputs.aws_region }} --cluster ${{ inputs.cluster_name }} --service ${{ inputs.cluster_name }}

0 commit comments

Comments
 (0)