-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (36 loc) · 1.27 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
name: Deploy site to production
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Clean earlier environment variables
run: rm site/.env.production || true
- name: Create environment variables
run: echo "${{ secrets.ENV_FILE }}" > site/.env.production
- name: Build docker image
run: docker build -t vtmunc/site ./site
- name: Remove environment variables file
run: rm site/.env.production || true
- name: Publish images to docker hub
run: docker push vtmunc/site:latest
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Pull docker image
run: docker pull vtmunc/site:latest
- name: Remove old containers
run: docker rm -f vtmunc || true
- name: Run container
run: docker run -p 3000:3000 -d --name vtmunc vtmunc/site
- name: Clean up (Removes old images)
run: docker system prune -f