Skip to content

Commit 0abb24e

Browse files
Copied github workflows from java template
1 parent 81f4761 commit 0abb24e

File tree

6 files changed

+691
-0
lines changed

6 files changed

+691
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: 'Deploy Docker Images'
2+
description: 'Deploy Docker images using Docker Compose and run smoke tests'
3+
inputs:
4+
environment:
5+
description: 'Target deployment environment (e.g., qa, staging, production)'
6+
required: true
7+
version:
8+
description: 'Release version to deploy (e.g., v1.0.4-rc)'
9+
required: true
10+
image-urls:
11+
description: 'Docker image URLs to deploy (JSON array format)'
12+
required: true
13+
14+
runs:
15+
using: 'composite'
16+
steps:
17+
- name: Deploy System
18+
run: |
19+
echo "🚀 Deploying system version ${{ inputs.version }} to ${{ inputs.environment }} environment..."
20+
echo ""
21+
22+
# List Docker images being deployed
23+
if [[ -n "${{ inputs.image-urls }}" ]]; then
24+
echo "📦 Deploying the following Docker images:"
25+
26+
# Parse JSON array and iterate through each URL
27+
echo '${{ inputs.image-urls }}' | jq -r '.[]' | while IFS= read -r image_url; do
28+
if [[ -n "$image_url" ]]; then
29+
echo " 🐳 Deploying: $image_url"
30+
fi
31+
done
32+
echo ""
33+
fi
34+
35+
echo "📝 Note: We are simulating deployment using Docker Compose Up for testing purposes."
36+
echo "🏭 In real applications, this is where you would deploy to:"
37+
echo " - AWS (ECS, EKS, Lambda, EC2)"
38+
echo " - Azure (Container Instances, AKS, App Service)"
39+
echo " - GCP (Cloud Run, GKE, Compute Engine)"
40+
echo " - On-premise (Kubernetes, Docker Swarm, VMs)"
41+
echo " - Other cloud providers (DigitalOcean, Linode, etc.)"
42+
echo ""
43+
echo "🐳 Starting Docker Compose for simulated deployment..."
44+
docker compose up -d
45+
shell: bash
46+
working-directory: system-test
47+
48+
- name: Wait for Application to be Ready
49+
uses: optivem/wait-for-docker-compose-action@v1
50+
with:
51+
url: 'http://localhost:8080/'
52+
max-attempts: '30'
53+
wait-seconds: '10'
54+
working-directory: system-test
55+
56+
- name: Setup Java
57+
uses: actions/setup-java@v4
58+
with:
59+
java-version: 25
60+
distribution: temurin
61+
62+
- name: Setup Gradle
63+
uses: gradle/actions/setup-gradle@v4
64+
65+
- name: Make Gradle Wrapper executable
66+
run: chmod +x ./gradlew
67+
shell: bash
68+
working-directory: system-test
69+
70+
- name: Run Smoke Tests
71+
run: ./gradlew test --tests com.optivem.atddaccelerator.template.systemtest.smoketests.*
72+
shell: bash
73+
working-directory: system-test
74+
75+
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: acceptance-stage
2+
3+
on:
4+
schedule:
5+
- cron: '*/30 * * * *' # Run every 30 minutes
6+
workflow_dispatch:
7+
inputs:
8+
force_run:
9+
description: 'Force run (even if no new images)'
10+
required: false
11+
default: false
12+
type: boolean
13+
14+
concurrency:
15+
group: acceptance-stage
16+
cancel-in-progress: true
17+
18+
jobs:
19+
20+
find-latest-images:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
image-digest-urls: ${{ steps.get-digest.outputs.image-digest-urls }}
24+
latest-image-timestamp: ${{ steps.get-digest.outputs.latest-image-timestamp }}
25+
26+
permissions:
27+
contents: read
28+
29+
steps:
30+
- name: Checkout Repository
31+
uses: actions/checkout@v4
32+
33+
- name: Resolve Latest Docker Digests
34+
id: get-digest
35+
uses: optivem/find-latest-docker-images-action@v1
36+
with:
37+
image-urls: |
38+
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/monolith:latest
39+
40+
should-run:
41+
needs: find-latest-images
42+
if: needs.find-latest-images.result == 'success'
43+
runs-on: ubuntu-latest
44+
outputs:
45+
should_run: ${{ steps.check.outputs.should-run }}
46+
steps:
47+
- name: Checkout Repository
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Should Run Acceptance Stage
53+
id: check
54+
uses: optivem/should-run-acceptance-stage-action@v1
55+
with:
56+
latest-image-timestamp: ${{ needs.find-latest-images.outputs.latest-image-timestamp }}
57+
force-run: ${{ inputs.force_run == true }}
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
62+
63+
system-test:
64+
needs: [should-run, find-latest-images]
65+
if: needs.should-run.outputs.should_run == 'true'
66+
runs-on: ubuntu-latest
67+
68+
permissions:
69+
contents: read
70+
71+
steps:
72+
- name: Checkout Repository
73+
uses: actions/checkout@v4
74+
75+
- name: Deploy System
76+
id: deploy-system
77+
uses: ./.github/actions/deploy-docker-images
78+
with:
79+
environment: acceptance
80+
version: latest
81+
image-urls: ${{ needs.find-latest-images.outputs.image-digest-urls }}
82+
83+
- name: Setup Java
84+
uses: actions/setup-java@v4
85+
with:
86+
java-version: 25
87+
distribution: temurin
88+
89+
- name: Setup Gradle
90+
uses: gradle/actions/setup-gradle@v4
91+
92+
- name: Make Gradle Wrapper executable
93+
run: chmod +x ./gradlew
94+
working-directory: system-test
95+
96+
- name: Run Acceptance Tests
97+
run: echo "Run Acceptance Tests"
98+
99+
- name: Run External System Contract Tests
100+
run: echo "Run External System Contract Tests"
101+
102+
- name: Run E2E Tests
103+
run: ./gradlew test --tests com.optivem.atddaccelerator.template.systemtest.e2etests.*
104+
working-directory: system-test
105+
106+
prerelease:
107+
needs: [find-latest-images, should-run, system-test]
108+
if: needs.system-test.result == 'success'
109+
runs-on: ubuntu-latest
110+
outputs:
111+
version: ${{ steps.generate-version.outputs.version }}
112+
image-urls: ${{ steps.tag-images.outputs.image-urls }}
113+
114+
permissions:
115+
contents: write
116+
packages: write
117+
118+
steps:
119+
- name: Checkout Repository
120+
uses: actions/checkout@v4
121+
with:
122+
fetch-depth: 0 # Fetch all history and tags
123+
124+
- name: Generate Prerelease Version
125+
id: generate-version
126+
uses: optivem/generate-prerelease-version-action@v1
127+
128+
- name: Tag Docker Images for Prerelease
129+
id: tag-images
130+
uses: optivem/tag-docker-images-action@v1
131+
with:
132+
image-urls: ${{ needs.find-latest-images.outputs.image-digest-urls }}
133+
tag: ${{ steps.generate-version.outputs.version }}
134+
env:
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136+
137+
- name: Create Prerelease
138+
id: create-release
139+
uses: optivem/create-release-action@v1
140+
with:
141+
base-version: latest
142+
release-version: ${{ steps.generate-version.outputs.version }}
143+
environment: acceptance
144+
status: prerelease
145+
artifact-urls: ${{ steps.tag-images.outputs.image-urls }}
146+
is-prerelease: true
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
150+
summary:
151+
needs: [find-latest-images, should-run, prerelease, system-test]
152+
if: always() # Run even if previous jobs fail
153+
runs-on: ubuntu-latest
154+
155+
steps:
156+
- name: Checkout Repository
157+
uses: actions/checkout@v4
158+
159+
- name: Acceptance Stage Summary
160+
uses: optivem/summarize-system-stage-action@v1
161+
with:
162+
stage-name: 'Acceptance Stage'
163+
environment: acceptance
164+
stage-result: ${{ needs.prerelease.result }}
165+
success-version: ${{ needs.prerelease.outputs.version }}
166+
success-artifact-ids: ${{ needs.prerelease.outputs.image-urls }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: commit-stage-monolith
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'monolith/**'
8+
- '.github/workflows/commit-stage-monolith.yml'
9+
pull_request:
10+
branches: [ "main" ]
11+
paths:
12+
- 'monolith/**'
13+
- '.github/workflows/commit-stage-monolith.yml'
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: commit-stage-monolith-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
24+
outputs:
25+
image-latest-url: ${{ steps.publish.outputs.image-latest-url }}
26+
image-digest-url: ${{ steps.publish.outputs.image-digest-url }}
27+
28+
permissions:
29+
contents: read
30+
packages: write
31+
32+
steps:
33+
- name: Checkout Repository
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Java
37+
uses: actions/setup-java@v4
38+
with:
39+
java-version: 25
40+
distribution: temurin
41+
42+
- name: Setup Gradle
43+
uses: gradle/actions/setup-gradle@v4
44+
45+
- name: Make Gradle Wrapper executable
46+
run: chmod +x ./gradlew
47+
shell: bash
48+
working-directory: monolith
49+
50+
- name: Build with Gradle Wrapper
51+
run: ./gradlew build
52+
working-directory: monolith
53+
54+
- name: Publish Docker Image
55+
id: publish
56+
uses: optivem/publish-docker-image-action@v1
57+
with:
58+
working-directory: monolith
59+
image-name: monolith
60+
registry: ghcr.io
61+
registry-username: ${{ github.actor }}
62+
image-namespace: ${{ github.repository }}
63+
image-latest-tag: latest
64+
commit-sha: ${{ github.sha }}
65+
dockerfile: Dockerfile
66+
env:
67+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
68+
69+
summary:
70+
needs: build
71+
runs-on: ubuntu-latest
72+
if: always()
73+
74+
steps:
75+
76+
- name: Commit Stage Summary
77+
uses: optivem/summarize-commit-stage-action@v1
78+
with:
79+
stage-result: ${{ needs.build.result }}
80+
success-artifact-url: ${{ needs.build.outputs.image-latest-url }}

0 commit comments

Comments
 (0)