Skip to content

Merge pull request #13 from snurfer0/chore/deployment #5

Merge pull request #13 from snurfer0/chore/deployment

Merge pull request #13 from snurfer0/chore/deployment #5

Workflow file for this run

name: CI/CD
env:
IMAGE_NAME: fundraiser-dapp
on:
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: "Set environment variables based on the current branch"
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "ENV_FILE_BASE64=${{ secrets.ENV_FILE_BASE64_PRODUCTION }}" >> "$GITHUB_ENV"
fi
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: 'Checkout repository'
uses: actions/checkout@v3
- name: 'Create .env file that will be used at build time'
run: |
touch .env
echo "${{ env.ENV_FILE_BASE64 }}" | base64 --decode >> .env
cat .env
- name: 'Log in to the Container registry'
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REGISTRY_HOST }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: "Build and push docker image"
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ secrets.DOCKER_REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:latest
- name: "Delete .env file used by Nest at build time"
run: |
rm .env