Skip to content

Merge pull request #922 from hngprojects/feat/fix-authentication #4

Merge pull request #922 from hngprojects/feat/fix-authentication

Merge pull request #922 from hngprojects/feat/fix-authentication #4

name: Build and Upload
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t hngdevops/nextjs-boilerplate:dev -f docker/development/Dockerfile .
- name: Save and compress Docker image
run: |
docker save hngdevops/nextjs-boilerplate:dev > nextjs-dev.tar
gzip nextjs-dev.tar
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: docker-image
path: nextjs-dev.tar.gz
copy-and-load-image:
needs: build
runs-on: ubuntu-latest
if: github.event.repository.fork == false
environment:
name: "dev"
url: ${{ vars.URL }}
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: docker-image
path: .
- name: Copy to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: "nextjs-dev.tar.gz"
target: "/tmp/nextjs"
- name: Load image in server
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd /tmp/nextjs
gunzip nextjs-dev.tar.gz
docker load < nextjs-dev.tar
rm -f nextjs-dev.tar