-
Notifications
You must be signed in to change notification settings - Fork 21
75 lines (74 loc) · 2.43 KB
/
pull-request-update.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
name: Pipeline
on: pull_request
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Get time of commit
run: echo "TIME=$(git log -1 --pretty=format:%ct)" >> $GITHUB_ENV
- name: Run tests in Docker image
uses: docker/build-push-action@v3
with:
context: ./
file: ./build/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
target: builder
tags: test-image
build-args: |
UPLOAD_COVERAGE=${{ true }}
GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha }}
GIT_BRANCH=${{ github.head_ref }}
GIT_COMMITTED_AT=${{ env.TIME }}
CC_TEST_REPORTER_ID=${{ secrets.CODE_CLIMATE_ID }}
BUILD=${{ false }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run tests with timezone
uses: docker/build-push-action@v3
with:
context: ./
file: ./build/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
target: builder
build-args: |
RUN_TESTS=${{ true }}
TZ=America/Detroit
BUILD=${{ false }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy-prod-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build and push PR image
uses: docker/build-push-action@v3
with:
context: ./
file: ./build/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: aamdigital/ndb-server:pr-${{ github.event.number }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy updated image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/docker/pr-${{ github.event.number }}
docker compose pull
docker compose up -d