Skip to content

feat: change 2566 to 67 #68

feat: change 2566 to 67

feat: change 2566 to 67 #68

name: 'Production Deployment'
on:
push:
branches:
- master
env:
IMAGE_REPO: ghcr.io/${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set env for production build
env:
BRANCH: ${{ github.ref }}
run: |
rm .env.production -rf
if [ $BRANCH = "refs/heads/master" ] ; then
cp envs/esc/.env.production .env.production
echo "PROJECT_NAME=election-frontend-production" >> $GITHUB_ENV
elif [ $BRANCH = "refs/heads/deploy-econ" ] ; then
cp envs/econ/.env.production .env.production
echo "PROJECT_NAME=election-frontend-econ-production" >> $GITHUB_ENV
echo "PATH_PREFIX=/econ" >> $GITHUB_ENV
elif [ $BRANCH = "refs/heads/dev" ] ; then
cp envs/esc/.env.development .env.production
echo "PROJECT_NAME=election-frontend-dev" >> $GITHUB_ENV
echo "PATH_PREFIX=/staging/election" >> $GITHUB_ENV
else
exit 1
fi
- name: Build the Docker image
run: docker build . --file Dockerfile --tag election-frontend-production --build-arg path_prefix=${{ env.PATH_PREFIX }}
- name: Docker login using Github Token
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Deploy Docker Image
run: |
docker tag election-frontend-production ${{ env.IMAGE_REPO }}/election-frontend-production
docker push ${{ env.IMAGE_REPO }}/election-frontend-production