Skip to content

chore: appease the linting overlords #57

chore: appease the linting overlords

chore: appease the linting overlords #57

Workflow file for this run

name: Deploy Service
run-name: Deploying ${{ inputs.service }}
on:
workflow_call:
inputs:
environment:
type: string
required: true
description: "where to deploy"
service:
type: string
required: true
description: "service to deploy"
version:
type: string
required: true
description: "version to deploy"
deploy-type:
type: choice
required: true
description: "deployment variant"
default: "instance"
options:
- binary
- instance
jobs:
deploy:
environment: ${{ inputs.environment }}
name: Deploy Service
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials for ${{ inputs.environment }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: us-east-1
- uses: actions/checkout@v4
if: ${{ inputs.service == 'web' }}
- uses: actions/setup-node@v4
if: ${{ inputs.service == 'web' }}
with:
node-version: '18.18.2'
- uses: pnpm/action-setup@v4
if: ${{ inputs.service == 'web' }}
- name: Install dependencies
if: ${{ inputs.service == 'web' }}
working-directory: app/web
run: pnpm install
- name: Build
if: ${{ inputs.service == 'web' }}
working-directory: app/web
run: pnpm run build
- name: Deploy
if: ${{ inputs.service == 'web' }}
uses: islishude/spa-deploy-action@v1
with:
dir-path: app/web/dist
s3-bucket: ${{ vars.WEB_HOSTING_BUCKET }}
- name: Invalidate web cache
if: ${{ inputs.service == 'web' }}
run: |
DIST_ID=${{ secrets.CLOUDFRONT_DIST_ID }}
# Create a CloudFront invalidation for all objects (/*)
invalidation_id=$(aws cloudfront create-invalidation --distribution-id $DIST_ID --paths "/*" --query 'Invalidation.Id' --output text)
# Check the status of the invalidation until it's completed
while [[ "$(aws cloudfront get-invalidation --distribution-id $DIST_ID --id $invalidation_id --query 'Invalidation.Status' --output text)" != "Completed" ]]; do
echo "Invalidation is still in progress. Waiting..."
sleep 5
done
echo "Invalidation is complete."
- name: Deploy service
if: ${{ inputs.service != 'web' && inputs.deploy-type == 'instance'}}
run: |
check_version_exists() {
local version="$1"
local service="$2"
local URL="https://artifacts.systeminit.com/${service}/${version}/omnibus/linux/x86_64/${service}-${version}-omnibus-linux-x86_64.tar.gz"
local check=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
[[ "$check" -eq 200 || "$check" -eq 301 ]]
}
poll_instance_refresh() {
local environment="$1"
local service="$2"
local id="$3"
while true; do
status=$(aws autoscaling describe-instance-refreshes \
--auto-scaling-group-name "${environment}-${service}" \
--query "InstanceRefreshes[?InstanceRefreshId=='${id}'].Status" \
--output text)
if [ -z "$status" ]; then
echo "No instance refresh found with ID ${id} for ${environment}-${service}."
break
fi
echo "Instance refresh status: $status"
if [[ "$status" == "Successful" ]]; then
echo "Instance refresh completed successfully."
break
elif [[ "$status" == "Failed" || "$status" == "Cancelled" ]]; then
echo "Instance refresh failed or was cancelled."
exit 1
else
echo "Instance refresh is still in progress. Waiting..."
sleep 15
fi
done
}
check_existing_refresh() {
local environment="$1"
local service="$2"
id=$(aws autoscaling describe-instance-refreshes \
--auto-scaling-group-name "${environment}-${service}"\
--query "InstanceRefreshes[?Status=='InProgress'].[InstanceRefreshId]"\
--output text)
poll_instance_refresh "$environment" "$service" "$id"
}
ENVIRONMENT="${{ inputs.environment }}"
SERVICE="${{ inputs.service }}"
VERSION="${{ inputs.version }}"
if check_version_exists "$VERSION" "$SERVICE"; then
echo "Checking if an instance refresh is already underway..."
check_existing_refresh "$ENVIRONMENT" "$SERVICE"
echo "Setting $SERVICE to $VERSION."
aws ssm put-parameter --name "${ENVIRONMENT}-si-version-$SERVICE" --value "$VERSION" --type "String" --overwrite
id=$(aws autoscaling start-instance-refresh \
--auto-scaling-group-name "${ENVIRONMENT}-${SERVICE}" \
--query 'InstanceRefreshId' --output text)
poll_instance_refresh "$ENVIRONMENT" "$SERVICE" "$id"
else
echo "Version $VERSION for $SERVICE not found in the artifacts registry. Skipping!"
exit 1
fi
- name: Deploy service
if: if: ${{ inputs.service != 'web' && inputs.deploy-type == 'binary' }}

Check failure on line 154 in .github/workflows/deploy-service.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy-service.yml

Invalid workflow file

You have an error in your yaml syntax on line 154
run: |
[[ ${{ inputs.environment }} == "tools" ]] && component/toolbox/awsi.sh upgrade -p tools-prod -r us-east-1 -a y -s ${{ inputs.service }}
[[ ${{ inputs.environment }} == "production" ]] && component/toolbox/awsi.sh upgrade -p si-apps-prod -r us-east-1 -a y -s ${{ inputs.service }}