-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (69 loc) · 2.58 KB
/
backend_guess_logic_number_cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: CD - build deploy guess_logic_number
on:
push:
branches:
- main
paths:
- '**'
jobs:
deploy:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17.1
env:
POSTGRES_USER: rouchdane
POSTGRES_PASSWORD: password
POSTGRES_DB: game
ports:
- 5332:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
defaults:
run:
working-directory: .
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Login to Docker Hub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set build number
id: build-number
run: echo "BUILD_NUMBER=$(date '+%d.%m.%Y.%H.%M.%S')" >> $GITHUB_OUTPUT
- name: run unit and integration test, Build app's docker image and replacing image tag with build_number value and Push to dockerhub
run: mvn -ntp -B verify -Ddocker.image.tag=${{steps.build-number.outputs.BUILD_NUMBER}} jib:build
- name: Update Dockerrun.aws.json with the newest application image tag which is build number
run: |
echo "Dockerrun.aws.json before updating tag"
cat Dockerrun.aws.json
sed -i -E 's_(rouchdane/guess_logic_number:)([^"]*)_\1'${{steps.build-number.outputs.BUILD_NUMBER}}'_' Dockerrun.aws.json
echo "Dockerrun.aws.json after updating tag"
cat Dockerrun.aws.json
- name: AWS Elastic Beanstalk Deploy the Updated Dockerrun.aws.json file
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: ${{ secrets.AWS_EB_APPLICATION_NAME }}
environment_name: ${{ secrets.AWS_EB_ENVIRONMENT_NAME }}
version_label: ${{steps.build-number.outputs.BUILD_NUMBER}}
version_description: ${{github.SHA}}
region: ${{ secrets.AWS_EB_REGION }}
deployment_package: Dockerrun.aws.json
- name: Commit and push Dockerrun.aws.json to our github repo
run: |
git config user.name github actions
git config user.email github actions@github.com
git add .
git commit -m "Update Dockerrun.aws.json specifically our docker app image with new tag ${{steps.build-number.outputs.BUILD_NUMBER}}"
git push