Skip to content

Squashed commit of the following: #223

Squashed commit of the following:

Squashed commit of the following: #223

Workflow file for this run

name: Build and Deploy
on:
push:
branches: [master, dev]
permissions:
contents: read
packages: write
pull-requests: write
repository-projects: read
env:
IMAGE_REPO: ghcr.io/${{ github.repository }}
jobs:
build-and-deploy:
strategy:
matrix:
node-version: [14.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker login using Github Token
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Switch to production environment
if: ${{ github.ref == 'refs/heads/master' }}
run: mv .env.prod .env
- name: Switch to development environment
if: ${{ github.ref == 'refs/heads/dev' }}
run: mv .env.dev .env
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.IMAGE_REPO }}
- name: Build and push to GitHub Packages
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.IMAGE_REPO }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_REPO }}:buildcache,mode=max
context: .
# - name: Deploy to VM
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SSH_HOST }}
# username: ${{ secrets.SSH_USERNAME }}
# key: ${{ secrets.SSH_KEY }}
# passphrase: ${{ secrets.SSH_PASSPHRASE }}
# script: |
# cd larngearcamp
# docker pull ${{ env.IMAGE_REPO }}:${{ steps.meta.outputs.version }}
# docker-compose up -d
# if [[ "$(docker images --filter "dangling=true" -q)" == "" ]]; then
# echo "No image with <none> tag"
# else
# docker rmi $(docker images --filter "dangling=true" -q) || true
# fi