diff --git a/.github/workflows/preproduction.yml b/.github/workflows/preproduction.yml new file mode 100644 index 00000000..718a49cb --- /dev/null +++ b/.github/workflows/preproduction.yml @@ -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 }} + diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index f1b1635c..1ccb40f5 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -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 }} @@ -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 }} diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml index d8f44672..4ade03bd 100644 --- a/.github/workflows/review.yml +++ b/.github/workflows/review.yml @@ -2,8 +2,8 @@ name: Review on: push: - branches: - - '**' + branches-ignore: + - master tags-ignore: - v*