-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from snurfer0/chore/deployment
chore: deployment action
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |