Skip to content

Commit

Permalink
fix(workflows): Split preprod and prod workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens committed Nov 29, 2021
1 parent e322470 commit f26feaa
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 44 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/preproduction.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Preproduction

on:
push:
branches:
- master
tags-ignore:
- v*

concurrency:
group: preproduction
cancel-in-progress: true

jobs:

##############################################################################
## BUILD AND REGISTER APPLICATION IMAGE
##############################################################################
register:
name: Build & Register application
runs-on: ubuntu-latest
steps:

- name: Get project name
run: |
echo "project=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Use autodevops build and register
uses: SocialGouv/actions/autodevops-build-register@v1
with:
environment: preprod
imageName: fabrique/carnets
project: ${{ env.project }}
token: ${{ secrets.GITHUB_TOKEN }}

##############################################################################
## BUILD AND REGISTER HASURA IMAGE
##############################################################################
register-hasura:
name: Build & Register Hasura
runs-on: ubuntu-latest
steps:

- name: Get project name
run: |
echo "project=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Use autodevops build and register
uses: SocialGouv/actions/autodevops-build-register@v1
with:
environment: preprod
imageName: fabrique/hasura
project: ${{ env.project }}
token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: ./packages/hasura/Dockerfile

##############################################################################
## GENERATE KUBERNETES MANIFESTS
##############################################################################
manifests:
name: Generate k8s manifests
runs-on: ubuntu-latest
steps:

- name: Use autodevops manifests generation
uses: SocialGouv/actions/autodevops-manifests@v1
with:
environment: preprod
rancherId: ${{ secrets.RANCHER_PROJECT_ID }}
socialgouvBaseDomain: ${{ secrets.SOCIALGOUV_BASE_DOMAIN }}

##############################################################################
## DEPLOY APPLICATION OVER KUBERNETES
##############################################################################
deploy:
name: Deploy application
runs-on: ubuntu-latest
needs: [register, register-hasura, manifests]
steps:

- name: Use autodevops deployment
uses: SocialGouv/actions/autodevops-deploy@v1
with:
environment: preprod
token: ${{ secrets.GITHUB_TOKEN }}
kubeconfig: ${{ secrets.KUBECONFIG }}
rancherId: ${{ secrets.RANCHER_PROJECT_ID }}

##############################################################################
## RESTORE DATABASE
##############################################################################
restore-db:
name: Restore database
runs-on: ubuntu-latest
needs: deploy
steps:

- name: Use autodevops database restore
uses: SocialGouv/actions/autodevops-restore-db@v1
with:
kubeconfig: ${{ secrets.KUBECONFIG }}
rancherId: ${{ secrets.RANCHER_PROJECT_ID }}
socialgouvBaseDomain: ${{ secrets.SOCIALGOUV_BASE_DOMAIN }}

50 changes: 8 additions & 42 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- name: Use autodevops build and register
uses: SocialGouv/actions/autodevops-build-register@v1
with:
environment: prod
imageName: fabrique/carnets
project: ${{ env.project }}
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -45,71 +46,36 @@ jobs:
- name: Use autodevops build and register
uses: SocialGouv/actions/autodevops-build-register@v1
with:
environment: prod
imageName: fabrique/hasura
project: ${{ env.project }}
token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: ./packages/hasura/Dockerfile

##############################################################################
## GENERATE PREPRODUCTION MANIFESTS
##############################################################################
manifests:
name: Preproduction manifests
runs-on: ubuntu-latest
steps:

- name: Use autodevops manifests generation
uses: SocialGouv/actions/autodevops-manifests@v1
with:
environment: "preprod"
rancherId: ${{ secrets.RANCHER_PROJECT_ID }}
socialgouvBaseDomain: ${{ secrets.SOCIALGOUV_BASE_DOMAIN }}

##############################################################################
## DEPLOY PREPRODUCTION APPLICATION
##############################################################################
deploy-preprod:
name: Deploy preproduction
runs-on: ubuntu-latest
needs: [register, register-hasura, manifests]
environment:
name: preproduction
url: ${{ steps.deploy-preprod.outputs.url }}
steps:

- name: Use autodevops deployment
uses: SocialGouv/actions/autodevops-deploy@v1
id: deploy-preprod
with:
environment: "preprod"
token: ${{ secrets.GITHUB_TOKEN }}
kubeconfig: ${{ secrets.KUBECONFIG }}
rancherId: ${{ secrets.RANCHER_PROJECT_ID }}

##############################################################################
## DEPLOY PRODUCTION APPLICATION
##############################################################################
deploy-prod:
deploy:
name: Deploy production
runs-on: ubuntu-latest
needs: [deploy-preprod]
needs: [register, register-hasura]
environment:
name: production
url: ${{ steps.deploy-prod.outputs.url }}
url: ${{ steps.deploy.outputs.url }}
steps:

- name: Use autodevops manifests generation
uses: SocialGouv/actions/autodevops-manifests@v1
with:
environment: "prod"
environment: prod
rancherId: ${{ secrets.RANCHER_PROJECT_ID }}
socialgouvBaseDomain: ${{ secrets.SOCIALGOUV_BASE_DOMAIN }}

- name: Use autodevops deployment
uses: SocialGouv/actions/autodevops-deploy@v1
id: deploy-prod
id: deploy
with:
environment: "prod"
environment: prod
token: ${{ secrets.GITHUB_TOKEN }}
kubeconfig: ${{ secrets.KUBECONFIG }}
rancherId: ${{ secrets.RANCHER_PROJECT_ID }}
4 changes: 2 additions & 2 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Review

on:
push:
branches:
- '**'
branches-ignore:
- master
tags-ignore:
- v*

Expand Down

0 comments on commit f26feaa

Please sign in to comment.