Skip to content

Merge pull request #44 from erland-syafiq/register-success #8

Merge pull request #44 from erland-syafiq/register-success

Merge pull request #44 from erland-syafiq/register-success #8

Workflow file for this run

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