Skip to content

Commit

Permalink
Deploy to prod on tag creation (#1064)
Browse files Browse the repository at this point in the history
## Fixes issue
#1030

## Description of Changes
Previously a push on the main branch triggered a deploy to prod. In the
future, creating a release will trigger that push.
The change is already built in a way that we can delete the main branch
and rename the develop branch to main as a next step (once we confirmed
everything works).
  • Loading branch information
abandoned-prototype authored Sep 23, 2023
1 parent c2395a9 commit 24a7605
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/build_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
name: Publish Docker image and deploy it

on:
release:
types: [published]
push:
branches:
- develop
- main
- develop

env:
image_name: lucyparsons/openoversight
# env_mapping: {"develop": "staging", "main": "prod"}
env_name: ${{ fromJson(vars.env_mapping)[github.ref_name] }}
# docker_mapping: {"develop": "latest", "main": "stable"}
docker_name: ${{ fromJson(vars.docker_mapping)[github.ref_name] }}
# env_name: 'prod' if ref_type is 'tag' indicating a release, otherwise 'staging'
env_name: ${{ github.ref_type == 'tag' && 'prod' || 'staging' }}
# docker_name: 'stable' if ref_type is 'tag', otherwise 'latest'
docker_name: ${{ github.ref_type == 'tag' && 'stable' || 'latest' }}
# release version if it is a release
release_version: ${{ github.ref_type == 'tag' && github.ref_name || 'latest'}}
python_version: "3.11"

jobs:
Expand Down Expand Up @@ -42,6 +46,7 @@ jobs:
ghcr.io/${{ env.image_name }}:${{ github.sha }}
ghcr.io/${{ env.image_name }}:${{ env.docker_name }}
ghcr.io/${{ env.image_name }}:${{ env.docker_name }}-py${{ env.python_version }}
ghcr.io/${{ env.image_name }}:${{ env.release_version }}
deploy:
name: Deploy code to respective server
needs: push_to_registry
Expand Down

0 comments on commit 24a7605

Please sign in to comment.