-
Notifications
You must be signed in to change notification settings - Fork 7
76 lines (73 loc) · 3.02 KB
/
frontend-react-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
name: CD - Deploy React Frontend
on:
workflow_dispatch:
push:
branches:
- main
paths:
- frontend/react/**
jobs:
deploy:
if: true
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend/react
steps:
- uses: actions/checkout@v3
- name: Slack commit message and sha
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":":github: ${{ github.server_url }}/${{ github.repository }}/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":":react: Deployment started :progress_bar: :fingerscrossed:"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- name: Set build number
id: build-number
run: echo "BUILD_NUMBER=$(date '+%d.%m.%Y.%H.%M.%S')" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Docker Build and push
run: |
chmod +x ../../.ci/build-publish.sh
USERNAME=rafalnowak444 \
REPO=device-management-react \
TAG=${{ steps.build-number.outputs.BUILD_NUMBER }} \
../../.ci/build-publish.sh . \
--build-arg api_base_url=http://DeviceManagement-env.eba-w3zq4zzm.eu-north-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/rafalnowak444/device-management-react"}'
${{ secrets.SLACK_WEBHOOK_URL }}
- 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: device-management
environment_name: Devicemanagement-env
version_label: device-management-source-v2-2
region: eu-north-1
- name: Send Slack Message
run: >
curl -X POST -H 'Content-type: application/json'
--data '{"text":"Deployment completed :github-check-mark: :party_blob: - http://Devicemanagement-env.eba-m3ctwxb5.eu-north-1.elasticbeanstalk.com/"}'
${{ 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 }}