Skip to content

create and deploy e38acbbc6884a46621bfa2eadef0a6fbea8d4f44 #17

create and deploy e38acbbc6884a46621bfa2eadef0a6fbea8d4f44

create and deploy e38acbbc6884a46621bfa2eadef0a6fbea8d4f44 #17

name: Create and deploy a new release
run-name: create and deploy ${{ github.sha }}
on:
push:
branches:
- ci-test
jobs:
check-commit-message:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check-commit.outputs.should_run }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check commit message
id: check-commit
run: |
COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.event.after }})
if [[ "$COMMIT_MESSAGE" == *"[deploy:prod:meteo]"* || \
"$COMMIT_MESSAGE" == *"[deploy:prod:ecologie]"* || \
"$COMMIT_MESSAGE" == *"[deploy:demo:ecologie]"* || \
"$COMMIT_MESSAGE" == *"[deploy:prod:defis]"* ]]; then
echo "::set-output name=should_run::true"
else
echo "No relevant commit message found, not running further jobs."
echo "::set-output name=should_run::false"
fi
trigger-gitlab-pipeline:
needs: check-commit-message
if: ${{ needs.check-commit-message.outputs.should_run == 'true' }}
runs-on: ubuntu-latest
env:
GITLAB_API_TOKEN: ${{ secrets.GITLAB_API_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: configure environment
shell: bash
run: |
COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.sha }})
if [[ "$COMMIT_MESSAGE" == *"[deploy:prod:meteo]"* ]]; then
echo "ENV_FILE=.env.meteo" >> $GITHUB_ENV
echo "APP_NAME=prod-meteo" >> $GITHUB_ENV
elif [[ "$COMMIT_MESSAGE" == *"[deploy:prod:ecologie]"* ]]; then
echo "ENV_FILE=.env.ecologie" >> $GITHUB_ENV
echo "APP_NAME=prod-ecologie" >> $GITHUB_ENV
elif [[ "$COMMIT_MESSAGE" == *"[deploy:demo:ecologie]"* ]]; then
echo "ENV_FILE=.env.ecologie" >> $GITHUB_ENV
echo "APP_NAME=demo-ecologie" >> $GITHUB_ENV
elif [[ "$COMMIT_MESSAGE" == *"[deploy:prod:defis]"* ]]; then
echo "ENV_FILE=.env.defis" >> $GITHUB_ENV
echo "APP_NAME=prod-defis" >> $GITHUB_ENV
else
echo "ENV_FILE not set due to no specific keywords found in the commit message."
fi
echo "REPO_PUBLIC_URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV
echo "BRANCH_NAME=main" >> $GITHUB_ENV
echo "SCAFFOLD_DIR=scaffold" >> $GITHUB_ENV
- name: clone scaffold repository
shell: bash
run: git clone --depth 1 https://oauth2:$GITLAB_API_TOKEN@${{ vars.SCAFFOLD_REPO_PUBLIC_URL }} -b test-udata-front-kit ${{ env.SCAFFOLD_DIR }}
- name: trigger Gitlab CI/CD pipeline
shell: bash
run: |
RELEASE_VERSION="${GITHUB_SHA:0:8}"
./scripts/gitlab-ci-pipeline.sh ${{ env.REPO_PUBLIC_URL }} ${{ env.APP_NAME }} $RELEASE_VERSION ${{ env.BRANCH_NAME }} ${{ env.ENV_FILE }}
working-directory: ${{ env.SCAFFOLD_DIR }}