Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: eu-west-2
aws-region: eu-central-1
role-session-name: GitHubActionsDeploy

- name: Verify AWS Credentials
run: aws sts get-caller-identity

- name: Log in to Amazon ECR
run: |
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ secrets.ECR_REPOSITORY }}
aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REPOSITORY }}

- name: Verify ECR Repository Exists
run: |
aws ecr describe-repositories --repository-names $(echo ${{ secrets.ECR_REPOSITORY }} | awk -F'/' '{print $NF}') --region eu-west-2
aws ecr describe-repositories --repository-names $(echo ${{ secrets.ECR_REPOSITORY }} | awk -F'/' '{print $NF}') --region eu-central-1

- name: Build and Push Docker Image
run: |
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
#!/bin/bash -eux
trap 'echo "Error on line \$LINENO"; exit 1' ERR

aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin "${ECR_REPO}"
aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin "${ECR_REPO}"

if docker container inspect link >/dev/null 2>&1; then
docker stop link >/dev/null 2>&1 || true
Expand Down Expand Up @@ -124,14 +124,14 @@ jobs:
--document-name "AWS-RunShellScript" \
--comment "Deploy LINK via GitHub Actions" \
--parameters file:///tmp/ssm-params.json \
--region eu-west-2 \
--region eu-central-1 \
--query 'Command.CommandId' --output text)

echo "Sent SSM command: $CMD_ID -> instance $INSTANCE_ID"

# Poll for status
for i in $(seq 1 30); do
STATUS=$(aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'Status' --output text --region eu-west-2 2>/dev/null || true)
STATUS=$(aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'Status' --output text --region eu-central-1 2>/dev/null || true)
echo "[$i] SSM status: ${STATUS:-Pending/NotReady}"
if [ "$STATUS" = "Success" ]; then
echo "SSM command succeeded"
Expand All @@ -140,14 +140,14 @@ jobs:
if [ "$STATUS" = "Failed" ] || [ "$STATUS" = "Cancelled" ] || [ "$STATUS" = "TimedOut" ]; then
echo "SSM command failed with status $STATUS"
echo "=== Stdout ==="
aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'StandardOutputContent' --output text --region eu-west-2 || true
aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'StandardOutputContent' --output text --region eu-central-1 || true
echo "=== Stderr ==="
aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'StandardErrorContent' --output text --region eu-west-2 || true
aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'StandardErrorContent' --output text --region eu-central-1 || true
exit 1
fi
sleep 5
done

echo "Timed out waiting for SSM command to succeed (last status: ${STATUS:-unknown})"
aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'StandardErrorContent' --output text --region eu-west-2 || true
exit 1
aws ssm get-command-invocation --command-id "$CMD_ID" --instance-id "$INSTANCE_ID" --query 'StandardErrorContent' --output text --region eu-central-1 || true
exit 1