Skip to content

create and deploy 6db8b83fcc3dcd3d4a30dcd4d871ec0c5820950a #626

create and deploy 6db8b83fcc3dcd3d4a30dcd4d871ec0c5820950a

create and deploy 6db8b83fcc3dcd3d4a30dcd4d871ec0c5820950a #626

name: Create and deploy a new release
run-name: create and deploy ${{ github.sha }}
on:
push:
branches:
- main
jobs:
trigger-gitlab-pipeline:
runs-on: ubuntu-latest
env:
# static variables and secrets to be defined
APP_NAME: ${{ vars.APP_NAME }}
SCAFFOLD_REPO_SSH_URL: ${{ vars.SCAFFOLD_REPO_SSH_URL }}
SCAFFOLD_DIR: "scaffold"
ENV: ""
GITLAB_API_TOKEN: ${{ secrets.GITLAB_API_TOKEN }}
DEPLOY_PRIVATE_KEY: ${{ secrets.DEPLOY_PRIVATE_KEY }}
steps:
- name: configure environment
shell: bash
run: |
# Set RELEASE_VERSION
echo "RELEASE_VERSION=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
# Set ENV based on branch name
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "ENV=dev" >> $GITHUB_ENV
fi
# Configure SSH private key for GitLab access
mkdir -p ~/.ssh
echo "$DEPLOY_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
# Configure Git identity
git config --global user.email "[email protected]"
git config --global user.name "datagouv"
- name: clone scaffold repository
shell: bash
run: |
git clone --quiet --depth 1 $SCAFFOLD_REPO_SSH_URL $SCAFFOLD_DIR
- name: trigger Gitlab CI/CD pipeline
shell: bash
run: |
# Run the script that triggers the Gitlab CI/CD pipeline.
# Must have GITLAB_API_TOKEN set in the environment
# GITLAB_API_TOKEN is the token related to the "infra" GitLab repository, so that the Gitlab CI/CD pipeline can be triggered
# The script args are, in order:
# - APP_NAME: the name of the project to deploy
# - RELEASE_VERSION: the version to deploy
# - ENV: the environment to deploy to
# - VARS: the optional deploy variables
./scripts/gitlab-ci-pipeline.sh $APP_NAME $RELEASE_VERSION $ENV ""
working-directory: ${{ env.SCAFFOLD_DIR }}