Skip to content

Commit

Permalink
chore: deployment action
Browse files Browse the repository at this point in the history
  • Loading branch information
snurfer0 committed Dec 9, 2023
1 parent 9c29314 commit ab3cdff
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deployer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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

0 comments on commit ab3cdff

Please sign in to comment.