-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a417b9c
commit e8634c8
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters