CD - Deploy React Frontend #12
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
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-m3ctwxb5.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 }} |