Skip to content

fix code

fix code #9

Workflow file for this run

name: Build and Deploy
# Controls when the action will run. Triggers the workflow on push or pull request
# events on the main branch
on:
push:
branches: [main]
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# container: node:16
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Build and Publish to Github Packages Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
NEXT_PUBLIC_BACKEND_URL: ${{ secrets.APP_NEXT_PUBLIC_BACKEND_URL }}
NEXT_PUBLIC_META_API_KEY: ${{ secrets.APP_NEXT_PUBLIC_META_API_KEY }}
with:
name: rahul-soshte/next-docker-github-actions/next_test_image
registry: ghcr.io
username: ${{ secrets.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
dockerfile: Dockerfile
buildargs: NEXT_PUBLIC_BACKEND_URL,NEXT_PUBLIC_META_API_KEY
tags: latest
- name: Deploy package to VPS
uses: appleboy/ssh-action@master
env:
GITHUB_USERNAME: ${{ secrets.USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
host: ${{ secrets.DEPLOY_HOST }}
# port: ${{ secrets.DEPLOY_PORT }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
envs: GITHUB_USERNAME, GITHUB_TOKEN
# TODO update APT and install Docker from the script so we don't need to do it manually on the server
script: |
docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN
# docker pull ghcr.io/rahul-soshte/next-docker-github-actions/next_test_image:latest
# docker stop next-test-app
# docker system prune -f
# docker run --name next-test-app -dit -p 12345:3000 ghcr.io/rahul-soshte/next-docker-github-actions/next_test_image:latest