Merge pull request #44 from erland-syafiq/register-success #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |