|
| 1 | +image: ubuntu:latest |
| 2 | + |
| 3 | +# Define global variables |
| 4 | +variables: |
| 5 | + ENVIRONMENT: "staging" |
| 6 | + WORKFLOW_REPO_URL: "https://$GITHUB_PAT@github.com/stack-spot/workflow-stackspot-actions-runtime-selfhosted.git" |
| 7 | + |
| 8 | +stages: |
| 9 | + - run_stackspot |
| 10 | + |
| 11 | +# Common setup steps for all jobs |
| 12 | +before_script: |
| 13 | + # Install necessary dependencies |
| 14 | + - apt-get -qq update |
| 15 | + - apt-get install -y curl git |
| 16 | + |
| 17 | + # Download and install STK CLI |
| 18 | + - curl -s -O "https://stk.stackspot.com/installer/linux/stk" |
| 19 | + - chmod +x stk |
| 20 | + - ./stk init |
| 21 | + |
| 22 | + - export STK=~/.stk/bin/stk |
| 23 | + |
| 24 | + # Verify STK CLI installation |
| 25 | + - $STK --version |
| 26 | + |
| 27 | +stk: |
| 28 | + stage: run_stackspot |
| 29 | + script: |
| 30 | + # Export environment variables for StackSpot |
| 31 | + - export INPUTS_CLIENT_ID=$STK_CLIENT_ID |
| 32 | + - export INPUTS_CLIENT_KEY=$STK_CLIENT_SECRET |
| 33 | + - export INPUTS_CLIENT_REALM=$STK_REALM |
| 34 | + - export INPUTS_TF_STATE_REGION=$AWS_REGION |
| 35 | + - export INPUTS_IAC_REGION=$AWS_REGION |
| 36 | + - export INPUTS_AWS_REGION=$AWS_REGION |
| 37 | + - export INPUTS_IAC_BUCKET_NAME=$IAC_BUCKET_NAME |
| 38 | + - export INPUTS_TF_STATE_BUCKET_NAME=$TF_STATE_BUCKET_NAME |
| 39 | + - export INPUTS_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID |
| 40 | + - export INPUTS_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY |
| 41 | + - export INPUTS_AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN |
| 42 | + - export INPUTS_ENVIRONMENT=$ENVIRONMENT |
| 43 | + |
| 44 | + # Authenticate with StackSpot |
| 45 | + - $STK login --client-id $INPUTS_CLIENT_ID --client-key $INPUTS_CLIENT_KEY --realm $INPUTS_CLIENT_REALM |
| 46 | + |
| 47 | + # Use the specified workspace |
| 48 | + - $STK use workspace $STK_WORKSPACE |
| 49 | + |
| 50 | + # Clone the workflow repository |
| 51 | + - git clone $WORKFLOW_REPO_URL |
| 52 | + - cd workflow-stackspot-actions-runtime-selfhosted |
| 53 | + - run_action_path=$(pwd) |
| 54 | + - cd .. |
| 55 | + |
| 56 | + # Run the StackSpot action |
| 57 | + - $STK run action $run_action_path --workflow_type deploy --version_tag $CI_JOB_ID --repository_name $CI_PROJECT_NAME --non-interactive |
0 commit comments