-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (100 loc) · 4.39 KB
/
frontend-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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: CD - Deploy Frontend
on:
workflow_dispatch:
push:
branches:
- master
paths:
- frontend/react/**
jobs:
deploy:
if: false
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend/react
steps:
- uses: actions/checkout@v4
- name: Slack commit message and sha
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":":github: https://github.com/kursph/spring-boot-project/commit/${{ github.sha }} - ${{ github.event.head_commit.message }}"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Send Slack Message
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":"Deployment started :progress_bar:"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Set build number
id: build-number
run: echo "BUILD_NUMBER=$(date '+%d.%m.%Y.%H.%M.%S')" >> $GITHUB_OUTPUT
- name: Send Slack Message
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":":docker: Building with Dockerx"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Docker Build and push
run: |
chmod +x ../../.ci/build-publish.sh
USERNAME=kurshjku \
REPO=kursph-react \
TAG=${{ steps.build-number.outputs.BUILD_NUMBER }} \
../../.ci/build-publish.sh . \
--build-arg api_base_url=http://kursph-spring-api-env.eba-rwavre5c.eu-central-1.elasticbeanstalk.com:8080
- name: Send Slack Message
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":":docker: Image tag:${{steps.build-number.outputs.BUILD_NUMBER}} pushed to https://hub.docker.com/repository/docker/kurshjku/kursph-react"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Update Dockerrun.aws.json api image tag with new build number
run: |
echo "Dockerrun.aws.json before updating tag"
cat ../../Dockerrun.aws.json
sed -i -E 's_(kurshjku/kursph-react:)([^"]*)_\1'${{steps.build-number.outputs.BUILD_NUMBER}}'_' ../../Dockerrun.aws.json
echo "Dockerrun.aws.json after updating tag"
cat ../../Dockerrun.aws.json
- name: Send Slack Message
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":":aws: Starting deployment to Elastic Beanstalk"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Deploy to Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: ${{ secrets.EB_APPLICATION_NAME }}
environment_name: ${{ secrets.EB_ENVIRONMENT_NAME }}
version_label: ${{ steps.build-number.outputs.BUILD_NUMBER }}
version_description: ${{ github.SHA }}
region: ${{ secrets.EB_REGION }}
deployment_package: Dockerrun.aws.json
wait_for_environment_recovery: 60
- name: Send Slack Message
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":":githubloading: Committing to repo https://github.com/kursph/spring-boot-project/"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Commit and push Dockerrun.aws.json
run: |
git config user.name github-actions
git config user.email [email protected]
git add ../../Dockerrun.aws.json
git commit -m "Update Dockerrun.aws.json docker image with new tag ${{ steps.build-number.outputs.BUILD_NUMBER }}"
git push
- name: Send Slack Message
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":"Deployment and commit completed :github-check-mark: - http://kursph-spring-api-env.eba-rwavre5c.eu-central-1.elasticbeanstalk.com/api/v1/customers"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Send Slack Message
if: always()
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":"Job Status ${{ job.status }}"}'
${{ secrets.SLACK_WEBHOOK_URL }}