Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release to Production #791

Merged
merged 13 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: build-deploy

on:
push:
branches:
- develop
tags:
- "[0-9]+.[0-9]+"

jobs:
set_environment:
outputs:
my_env: ${{ steps.setenv.outputs.my_env }}
tag: ${{ steps.setenv.outputs.tag }}
runs-on: ubuntu-latest
steps:
- id: setenv
run: |
if [ $GITHUB_REF_NAME == develop ]; then
echo "my_env=dev" >> $GITHUB_OUTPUT
echo "tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
fi
if [[ $GITHUB_REF_NAME =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "release tag: $GITHUB_REF_NAME"
echo "tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
echo "my_env=production" >> $GITHUB_OUTPUT
fi

release:
runs-on: ubuntu-latest
needs: set_environment
environment:
name: ${{ needs.set_environment.outputs.my_env }}
name: ${{ needs.set_environment.outputs.my_env }}-release
steps:
- name: Clone Reusable Actions Repo
run: |
git clone -b master https://${{ secrets.GIT_TOKEN }}@github.com/crowdbotics/github-actions.git

- name: Azure login
uses: azure/[email protected]
with:
creds: "${{ secrets.AZURE_CREDENTIALS }}"

- name: Set up kubelogin for non-interactive login
uses: azure/use-kubelogin@v1
with:
kubelogin-version: "v0.0.25"

- name: Get K8s context
uses: azure/aks-set-context@v4
with:
resource-group: ${{ secrets.AZURE_RESOURCE_GROUP }}
cluster-name: ${{ secrets.AZURE_CLUSTER_NAME }}
admin: "false"
use-kubelogin: "true"

- name: Update DJANGO_SCAFFOLD_REPO_BRANCH
id: update-env-var
uses: ./github-actions/set-azure-env-var
with:
resource_group: ${{ secrets.AZURE_RESOURCE_GROUP }}
cluster_name: ${{ secrets.AZURE_CLUSTER_NAME }}
app_name: crowdbotics-app
app_namespace: cb-core
env_var: DJANGO_SCAFFOLD_REPO_BRANCH
env_value: ${{ needs.set_environment.outputs.tag }}
token: ${{ secrets.GIT_TOKEN }}
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}

- uses: act10ns/slack@v2
if: ${{ needs.set_environment.outputs.my_env }} == 'production'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
20 changes: 9 additions & 11 deletions .github/workflows/create-github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ jobs:
runs-on: ubuntu-latest
env:
working-directory: ./django-scaffold
environment: production
steps:
- name: Repo Clone
id: repo-clone
run: |
git clone https://${{ secrets.GIT_TOKEN }}@github.com/crowdbotics/django-scaffold.git

- name: Clone Reusable Actions Repo
id: reusable-actions-clone
run: |
git clone -b master https://${{ secrets.GIT_TOKEN }}@github.com/crowdbotics/github-actions.git

- name: Checkout branch
id: checkout
Expand All @@ -48,12 +42,16 @@ jobs:

- name: Update DJANGO_SCAFFOLD_REPO_BRANCH Environment Variable
id: update-env-var
uses: ./github-actions/publish-release-sha
uses: ./github-actions/set-azure-env-var
with:
heroku_api_key: ${{ secrets.HEROKU_API_TOKEN }}
heroku_app_name: 'crowdbotics-slack'
git_sha: ${{ steps.release.outputs.tag_version }}
env_var_name: 'DJANGO_SCAFFOLD_REPO_BRANCH'
resource_group: ${{ secrets.AZURE_RESOURCE_GROUP }}
cluster_name: ${{ secrets.AZURE_CLUSTER_NAME }}
app_name: crowdbotics-app
app_namespace: cb-core
env_var: DJANGO_SCAFFOLD_REPO_BRANCH
env_value: ${{ steps.release.outputs.tag_version }}
token: ${{ secrets.TOKEN }}
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}

- uses: act10ns/slack@v2
env:
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ django-allauth = "~=0.54.0"
django-extensions = "~=3.2.3"
packaging = "*"
pyyaml = "~=6.0"
pillow = "~=10.3.0"
pytest = "==7.4.3"
pillow = "~=10.4.0"
pytest = "==8.3.1"
factory-boy = "==3.3.0"
google-cloud-secret-manager = "==2.20.1"
google-auth = "==2.31.0"
Expand Down
167 changes: 89 additions & 78 deletions {{cookiecutter.project_slug}}/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.