-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (48 loc) · 2 KB
/
deploy.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
# Specifies name of workflow in the repo's Action's tab
name: Deploy Frontend
# Defines when Action should run. Action is triggered by a push event to the main branch of the repo.
on:
push:
branches:
- main
pull_request:
branches:
- main
# A job is a collection of steps that run on a certain "runner" (server or machine that executes tasks in an Actions workflow--in this case, ubuntu).
# This job is named "test" and will run on an "ubuntu-latest" virtual environment. Ubuntu is pre-configured and provided for Actions.
jobs:
test:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
# Checks out code from repo.
- name: Check out code
uses: actions/checkout@v3
# Authenticates Docker registry through secrets.
- name: Log in to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# Builds Docker image.
- name: Build Docker image for testing
run: docker build -t achuribooks/docker-react -f Dockerfile.dev .
# Runs tests in specified container file via Node.js, sets environment variable (-e) of "CI" (continuous integration) to "true," supressing certain features, like prompts.
- name: Run tests
run: docker run -e CI=true achuribooks/docker-react npm test
deploy:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Generate deployment package
run: zip -r deploy.zip . -x '*.git*'
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v18
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: frontend
environment_name: frontend-env
existing_bucket_name: elasticbeanstalk-us-east-1-140023362796
region: us-east-1
version_label: ${{ github.sha }}
deployment_package: deploy.zip