-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (91 loc) · 3.24 KB
/
main.yml
File metadata and controls
105 lines (91 loc) · 3.24 KB
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
103
104
105
name: postgres
on: push
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# Label of the container job
workflow-pipeline:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:11.7
# Provide the password for postgres
env:
POSTGRES_USER: ${{ secrets.PG_USERNAME }}
POSTGRES_PASSWORD: ${{ secrets.PG_PASSWORD }}
POSTGRES_DB: ${{ secrets.PG_DATABASE }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SERVICE_ID: ${{ secrets.SERVICE_ID }}
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }}
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v3
# Perform the rest of the original steps
- name: Install dependencies
run: cd todo-app && npm ci
- name: Run unit tests
run: cd todo-app && npm test
- name: Run the app
id: run-app
run: |
cd todo-app
npm install
npx sequelize-cli db:drop
npx sequelize-cli db:create
npx sequelize-cli db:migrate
PORT=3000 npm start &
sleep 5
- name: Run integration tests
run: |
cd todo-app
npm install cypress cypress-json-results
npx cypress run --env STUDENT_SUBMISSION_URL="http://localhost:3000/"
# Perform Docker actions
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PERSONAL_ACCESS }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: ./todo-app
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Deploy to production
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.SERVICE_ID }}
api-key: ${{ secrets.RENDER_API_KEY }}
- name: Slack Notification
uses: act10ns/slack@v1
with:
status: ${{ job.status }}
channel: '#pipeline'
message: |
Build and Deploy Status: ${{ job.status }}
Job Name: ${{ github.job }}
Workflow: ${{ github.workflow }}
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
# if: failure()