Skip to content

Commit

Permalink
debug gha
Browse files Browse the repository at this point in the history
  • Loading branch information
pitiscarf committed Nov 18, 2024
1 parent b465f2d commit 71128ba
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 18 deletions.
102 changes: 88 additions & 14 deletions .github/workflows/wip-create-environment.yml
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 }}
2 changes: 1 addition & 1 deletion .github/workflows/wip-deploy-ci-admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "packages/**"
- ".github/workflows/wip-deploy-ci-admin.yml" # TODO: remove
branches: # TODO: remove me
- 3577-app
- 3577-app-disable

env:
ENVIRONMENT: ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wip-deploy-ci-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "packages/**"
- ".github/workflows/wip-deploy-ci-api.yml" # TODO: remove
branches: # TODO: remove me
- 3577-app
- 3577-app-disable

env:
ENVIRONMENT: ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wip-deploy-ci-apiv2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "packages/**"
- ".github/workflows/wip-deploy-ci-apiv2.yml" # TODO: remove
branches: # TODO: remove me
- 3577-app
- 3577-app-disable

env:
ENVIRONMENT: ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wip-deploy-ci-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "packages/**"
- ".github/workflows/wip-deploy-ci-app.yml" # TODO: remove
branches: # TODO: remove me
- 3577-app
- 3577-app-disable

env:
ENVIRONMENT: ci
Expand Down

0 comments on commit 71128ba

Please sign in to comment.