-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
92 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,111 @@ | ||
name: Create environment | ||
|
||
on: | ||
create: | ||
workflow_dispatch: | ||
# push: | ||
# branches: # TODO: remove me | ||
# - 3577-app | ||
push: | ||
branches: # TODO: remove me | ||
- 3577-app | ||
|
||
defaults: | ||
run: | ||
working-directory: devops/scripts | ||
|
||
jobs: | ||
test: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
branch_name: ${{ steps.check.outputs.branch_name }} | ||
env_name: ${{ steps.prepare.outputs.env_name }} | ||
api_image_tag: ${{ steps.prepare.outputs.api_image_tag }} | ||
admin_image_tag: ${{ steps.prepare.outputs.admin_image_tag }} | ||
app_image_tag: ${{ steps.prepare.outputs.app_image_tag }} | ||
|
||
steps: | ||
- name: Check branch name | ||
id: check | ||
run: | | ||
if [[ ${{ github.event_name }} == 'pull_request' ]] ; then | ||
branch_name=${{ github.head_ref }} | ||
else | ||
branch_name=${{ github.ref_name }} | ||
fi | ||
if [[ $branch_name == 'main' ]] || [[ $branch_name == 'production' ]] ; then | ||
echo "This action is not available on the branch $branch_name" | ||
exit 1 | ||
fi | ||
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ steps.check.outputs.branch_name }} | ||
fetch-depth: 0 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18.20" | ||
|
||
- name: Get environment name | ||
id: env_name | ||
# TODO : replace with ${{ github.event.ref }} | ||
- name: Prepare | ||
id: prepare | ||
run: | | ||
env_name=$(node get-environment-name.js ${{ github.ref_name }}) | ||
echo ${{ github.event }} | ||
env_name=$(node get-environment-name.js ${{ steps.check.outputs.branch_name }}) | ||
echo "env_name: $env_name" | ||
echo "env_name=$env_name" >> $GITHUB_OUTPUT | ||
- name: Create environment | ||
env: | ||
SCW_SECRET_KEY: ${{ secrets.SCW_CI_DEPLOY_SECRET_KEY }} | ||
SCW_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID }} | ||
run: node create-environment.js ${{ steps.env_name.outputs.env_name }} | ||
api_image_tag=$(git log --max-count=1 --oneline -- api packages package-lock.json | cut -d " " -f 1) | ||
echo "api_image_tag: $api_image_tag" | ||
echo "api_image_tag=$api_image_tag" >> $GITHUB_OUTPUT | ||
admin_image_tag=$(git log --max-count=1 --oneline -- admin packages package-lock.json | cut -d " " -f 1) | ||
echo "admin_image_tag: $admin_image_tag" | ||
echo "admin_image_tag=$admin_image_tag" >> $GITHUB_OUTPUT | ||
app_image_tag=$(git log --max-count=1 --oneline -- app packages package-lock.json | cut -d " " -f 1) | ||
echo "app_image_tag: $app_image_tag" | ||
echo "app_image_tag=$app_image_tag" >> $GITHUB_OUTPUT | ||
# run_tests_api: | ||
# needs: prepare | ||
# uses: ./.github/workflows/run-tests-api-pr.yml | ||
# with: | ||
# branch_name: ${{ needs.prepare.outputs.branch_name }} | ||
# secrets: inherit | ||
|
||
# run_tests_front: | ||
# needs: prepare | ||
# uses: ./.github/workflows/run-tests-front.yml | ||
# with: | ||
# branch_name: ${{ needs.prepare.outputs.branch_name }} | ||
# secrets: inherit | ||
|
||
# run_tests_lib: | ||
# needs: prepare | ||
# uses: ./.github/workflows/run-tests-lib.yml | ||
# with: | ||
# branch_name: ${{ needs.prepare.outputs.branch_name }} | ||
# secrets: inherit | ||
# test: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
|
||
# - name: Use Node.js | ||
# uses: actions/setup-node@v4 | ||
# with: | ||
# node-version: "18.20" | ||
|
||
# - name: Get environment name | ||
# id: env_name | ||
# # TODO : replace with ${{ github.event.ref }} | ||
# run: | | ||
# env_name=$(node get-environment-name.js ${{ github.ref_name }}) | ||
# echo "env_name: $env_name" | ||
# echo "env_name=$env_name" >> $GITHUB_OUTPUT | ||
|
||
# - name: Create environment | ||
# env: | ||
# SCW_SECRET_KEY: ${{ secrets.SCW_CI_DEPLOY_SECRET_KEY }} | ||
# SCW_ORGANIZATION_ID: ${{ secrets.SCW_ORGANIZATION_ID }} | ||
# run: node create-environment.js ${{ steps.env_name.outputs.env_name }} |
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
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
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
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