Skip to content

Commit

Permalink
Merge pull request #3 from cyber-dojo/add-ci-env-vars
Browse files Browse the repository at this point in the history
Add env-vars in ci pipelines
  • Loading branch information
JonJagger authored Mar 4, 2024
2 parents 09e7b47 + 3c08b23 commit 4071994
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ env:
KOSLI_HOST: ${{ vars.KOSLI_HOST }} # https://app.kosli.com
KOSLI_HOST_STAGING: ${{ vars.KOSLI_HOST_STAGING }} # https://staging.app.kosli.com
KOSLI_ORG: ${{ vars.KOSLI_ORG }} # cyber-dojo
KOSLI_FLOW: runner-ci
KOSLI_FLOW: ${{ vars.KOSLI_FLOW }} # runner-ci
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}
KOSLI_TRAIL: ${{ github.sha }}
SERVICE_NAME: ${{ github.event.repository.name }} # runner

jobs:

Expand Down Expand Up @@ -44,7 +45,7 @@ jobs:
run: |
IMAGE_TAG=${GITHUB_SHA:0:7}
echo "image_tag=${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
echo "image_name=cyberdojo/runner:${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
echo "image_name=cyberdojo/${{ env.SERVICE_NAME }}:${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
pull-request:
Expand Down Expand Up @@ -307,7 +308,7 @@ jobs:
runs-on: ubuntu-latest
environment:
name: staging
url: ${{ vars.KOSLI_HOST_STAGING }}
url: https://beta.cyber-dojo.org
env:
IMAGE_NAME: ${{ needs.kosli-trail.outputs.image_name }}
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.kosli_fingerprint }}
Expand Down Expand Up @@ -343,7 +344,7 @@ jobs:
runs-on: ubuntu-latest
environment:
name: production
url: ${{ vars.KOSLI_HOST }}
url: https://beta.cyber-dojo.org
env:
IMAGE_NAME: ${{ needs.kosli-trail.outputs.image_name }}
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.kosli_fingerprint }}
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/main_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ on:
- main

env:
KOSLI_DRY_RUN: ${{ vars.KOSLI_DRY_RUN }} # False
KOSLI_HOST: ${{ vars.KOSLI_HOST_STAGING }} # https://staging.app.kosli.com
KOSLI_ORG: ${{ vars.KOSLI_ORG }} # cyber-dojo
KOSLI_FLOW: runner-ci
KOSLI_DRY_RUN: ${{ vars.KOSLI_DRY_RUN }} # False
KOSLI_HOST: ${{ vars.KOSLI_HOST_STAGING }} # https://staging.app.kosli.com
KOSLI_ORG: ${{ vars.KOSLI_ORG }} # cyber-dojo
KOSLI_FLOW: ${{ vars.KOSLI_FLOW }} # runner-ci
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN_STAGING }}
KOSLI_TRAIL: ${{ github.sha }}
SERVICE_NAME: ${{ github.event.repository.name }} # runner

jobs:

Expand Down Expand Up @@ -43,7 +44,7 @@ jobs:
run: |
IMAGE_TAG=${GITHUB_SHA:0:7}
echo "image_tag=${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
echo "image_name=cyberdojo/runner:${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
echo "image_name=cyberdojo/${{ env.SERVICE_NAME }}:${IMAGE_TAG}" >> ${GITHUB_OUTPUT}
pull-request:
Expand Down Expand Up @@ -407,5 +408,5 @@ jobs:
- name: Tag image to :latest and push to Dockerhub Registry
run: |
docker pull "${IMAGE_NAME}"
docker tag "${IMAGE_NAME}" cyberdojo/runner:latest
docker push cyberdojo/runner:latest
docker tag "${IMAGE_NAME}" cyberdojo/${{ env.SERVICE_NAME }}:latest
docker push cyberdojo/${{ env.SERVICE_NAME }}:latest
11 changes: 6 additions & 5 deletions .github/workflows/sub_deploy_to_beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ on:


env:
KOSLI_ORG: cyber-dojo
KOSLI_FLOW: runner-ci
KOSLI_TRAIL: ${{ github.sha }}
KOSLI_DRY_RUN: ${{ vars.KOSLI_DRY_RUN }} # False
KOSLI_HOST: "https://app.kosli.com"
KOSLI_HOST_STAGING: "https://staging.app.kosli.com"

KOSLI_ORG: ${{ vars.KOSLI_ORG }} # cyber-dojo
KOSLI_FLOW: ${{ vars.KOSLI_FLOW }} # runner-ci
KOSLI_TRAIL: ${{ github.sha }}
SERVICE_NAME: ${{ github.event.repository.name }} # runner

jobs:

Expand All @@ -36,7 +37,7 @@ jobs:
- name: Prepare outputs for fivexl deployment workflow
id: vars
run: |
echo "service_name=runner" >> ${GITHUB_OUTPUT}
echo "service_name=${{ env.SERVICE_NAME }}" >> ${GITHUB_OUTPUT}
echo "image_tag=${{ inputs.IMAGE_TAG }}" >> ${GITHUB_OUTPUT}
echo "aws_account_id=244531986313" >> ${GITHUB_OUTPUT}
echo "ecr_registry=244531986313.dkr.ecr.eu-central-1.amazonaws.com" >> ${GITHUB_OUTPUT}
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/sub_deploy_to_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ on:


env:
KOSLI_ORG: cyber-dojo
KOSLI_FLOW: runner-ci
KOSLI_TRAIL: ${{ github.sha }}
KOSLI_DRY_RUN: ${{ vars.KOSLI_DRY_RUN }} # False
KOSLI_HOST: "https://app.kosli.com"
KOSLI_HOST_STAGING: "https://staging.app.kosli.com"
KOSLI_ORG: ${{ vars.KOSLI_ORG }} # cyber-dojo
KOSLI_FLOW: ${{ vars.KOSLI_FLOW }} # runner-ci
KOSLI_TRAIL: ${{ github.sha }}
SERVICE_NAME: ${{ github.event.repository.name }} # runner

jobs:

Expand All @@ -35,7 +37,7 @@ jobs:
- name: Prepare outputs for fivexl deployment workflow
id: vars
run: |
echo "service_name=runner" >> ${GITHUB_OUTPUT}
echo "service_name=${{ env.SERVICE_NAME }}" >> ${GITHUB_OUTPUT}
echo "image_tag=${{ inputs.IMAGE_TAG }}" >> ${GITHUB_OUTPUT}
echo "aws_account_id=274425519734" >> ${GITHUB_OUTPUT}
echo "ecr_registry=274425519734.dkr.ecr.eu-central-1.amazonaws.com" >> ${GITHUB_OUTPUT}
Expand Down
6 changes: 3 additions & 3 deletions sh/wait_for_deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ image_not_deployed()
docker pull "${IMAGE_NAME}"
FINGERPRINT=$(kosli fingerprint "${IMAGE_NAME}" --artifact-type=docker)

MAX_WAIT_TIME=$((8 * 60)) # max time to wait for image to be deployed
SLEEP_TIME=15 # wait time between deployment checks
MAX_ATTEMPTS=$(( MAX_WAIT_TIME / SLEEP_TIME ))
MAX_WAIT_TIME=15 # max time to wait for image to be deployed, in minutes
SLEEP_TIME=20 # wait time between deployment checks, in seconds
MAX_ATTEMPTS=$(( MAX_WAIT_TIME * 60 / SLEEP_TIME ))
ATTEMPTS=1

until image_deployed
Expand Down

0 comments on commit 4071994

Please sign in to comment.