forked from WildCodeSchool/2309-wns-jaune-wild-code-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (74 loc) · 2.95 KB
/
dev-cd.yml
File metadata and controls
84 lines (74 loc) · 2.95 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
name: Compile and push client and server image for staging
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the dev branch
pull_request:
branches: ["dev"]
types:
- closed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# if pull request merged
if: github.event.pull_request.merged == true
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# login with Docker
- uses: docker/login-action@v2
name: Login to Docker Hub
with:
# generate some credentials from Dockerhub and store them into the repo secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# prepare buildx for docker
- uses: docker/setup-buildx-action@v2
name: Set up Docker Buildx
# build and push the newly created image backend
- uses: docker/build-push-action@v4
name: Build and push backend
with:
context: ./backend
file: ./backend/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/dev-server-backend:latest
# build and push the newly created image frontend
- uses: docker/build-push-action@v4
name: Build and push frontend
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/dev-server-frontend:latest
# deployment:
# needs: build
# runs-on: ubuntu-latest
# # send deploiement hook
# steps:
# - name: Invoke deployment hook
# uses: distributhor/workflow-webhook@v3
# with:
# webhook_url: ${{ secrets.WEBHOOK_URL_DEV }}
deployment:
needs: build
runs-on: ubuntu-latest
steps:
- name: Invoke deployment hook
env:
SECRET_KEY: ${{ secrets.WEBHOOK_SECRET }}
run: |
PAYLOAD='{}'
SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET_KEY" | awk '{print $2}')
SIGNATURE="sha256=$SIGNATURE"
curl -X POST -H "Content-Type: application/json" -H "X-Hub-Signature: $SIGNATURE" -d "$PAYLOAD" ${{ secrets.WEBHOOK_URL_DEV }}
# run: |
# PAYLOAD='{}'
# SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha1 -hmac "$SECRET_KEY" | sed 's/^.* //')
# SIGNATURE="sha1=$SIGNATURE"
# curl -X POST -H "Content-Type: application/json" -H "X-Hub-Signature: $SIGNATURE" -d "$PAYLOAD" ${{ secrets.WEBHOOK_URL_DEV }}