Mise en production #107
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
name: Mise en production | |
on: | |
workflow_dispatch: | |
inputs: | |
purge_cloudflare_cache: | |
description: 'Faut-il vider le cache Cloudflare après le déploiement ?' | |
type: boolean | |
default: false | |
jobs: | |
backup: | |
name: Sauvegarder la base de données PostgreSQL | |
runs-on: ubuntu-latest | |
environment: | |
name: scalingo-production | |
url: https://www.1jeune1solution.gouv.fr | |
steps: | |
- name: Configurer la CLI Scalingo | |
uses: scalingo-community/[email protected] | |
with: | |
api_token: ${{ secrets.SCALINGO_API_TOKEN }} | |
region: ${{ vars.SCALINGO_REGION }} | |
app_name: ${{ secrets.TF_VAR_NOM_DE_L_APPLICATION }} | |
- name: Créer une sauvegarde de la base PostgreSQL Scalingo | |
run: | | |
POSTGRESQL_ADDON_ID=$(scalingo addons | grep -i postgresql | awk 'BEGIN{FS=" [|] "}{print $2}') | |
scalingo backups-create --addon $POSTGRESQL_ADDON_ID | |
terraform: | |
uses: DNUM-SocialGouv/1j1s-front/.github/workflows/terraform-template.yml@main | |
secrets: inherit | |
with: | |
apply: true | |
environnement_name: scalingo-production | |
environnement_url: https://www.1jeune1solution.gouv.fr | |
concurrency: terraform-state-production # Evite les conflits sur le state Terraform | |
scalingo: | |
name: Déployer le code sur Scalingo | |
needs: [terraform, backup] | |
runs-on: ubuntu-latest | |
environment: | |
name: scalingo-production | |
url: https://www.1jeune1solution.gouv.fr | |
steps: | |
- name: Configurer la CLI Scalingo | |
uses: scalingo-community/[email protected] | |
with: | |
api_token: ${{ secrets.SCALINGO_API_TOKEN }} | |
region: ${{ vars.SCALINGO_REGION }} | |
app_name: ${{ secrets.TF_VAR_NOM_DE_L_APPLICATION }} | |
- name: Déployer le code sur Scalingo | |
run: | | |
scalingo integration-link-manual-deploy main | |
cloudflare: | |
name: Purger le cache Cloudflare | |
needs: scalingo | |
runs-on: ubuntu-latest | |
if: ${{ inputs.purge_cloudflare_cache == true }} | |
steps: | |
- name: Purger le cache Cloudflare | |
uses: nathanvaughn/[email protected] | |
with: | |
cf_zone: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
cf_auth: ${{ secrets.CLOUDFLARE_API_TOKEN }} |