Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/aws_auto_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
if: steps.auth_check.outputs.is_authorized == 'true' && steps.check.outputs.should_release == 'true'
uses: actions/setup-node@v4
with:
node-version: 20.10
node-version: ${{ vars.node_version }}

- name: Calculate new version with cumulative bumps
if: steps.auth_check.outputs.is_authorized == 'true' && steps.check.outputs.should_release == 'true'
Expand Down
41 changes: 33 additions & 8 deletions .github/workflows/aws_dev_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,39 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20.10
node-version: ${{ vars.node_version }}
cache: 'npm'
- run: npm i
- run: CI=false npm run build

- name: Build
run: |
set +e
CI=false npm run build 2>&1 | tee /tmp/build.log
BUILD_EXIT=${PIPESTATUS[0]}
set -e
if [ $BUILD_EXIT -ne 0 ] || grep -q "npm ERR!" /tmp/build.log; then
echo "::error::Build failed"
exit 1
fi

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,amd64


- name: Get role ARN
id: get_role
env:
ARN_JSON: ${{ secrets.AWS_ROLE_ARN }}
run: |
arn=$(echo "$ARN_JSON" | jq -r '.dev')
echo "::add-mask::$arn"
echo "arn=$arn" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::368076259134:role/github-actions-role
role-to-assume: ${{ steps.get_role.outputs.arn }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
Expand All @@ -79,7 +96,7 @@ jobs:
tags: |
type=raw,value=${{ github.event.repository.name }}



- name: Build and push multi-platform images to ECR
uses: docker/build-push-action@v5
Expand All @@ -103,10 +120,18 @@ jobs:
matrix:
service: ${{ fromJson(needs.Build.outputs.service) }}
steps:
- name: Get role ARN
id: get_role
env:
ARN_JSON: ${{ secrets.AWS_ROLE_ARN }}
run: |
arn=$(echo "$ARN_JSON" | jq -r '.dev')
echo "::add-mask::$arn"
echo "arn=$arn" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::368076259134:role/github-actions-role
role-to-assume: ${{ steps.get_role.outputs.arn }}
aws-region: us-east-1

- name: deploy
Expand Down
43 changes: 34 additions & 9 deletions .github/workflows/aws_prod_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,42 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20.10
node-version: ${{ vars.node_version }}
cache: 'npm'
- run: git config --global user.email devops@topia.io
- run: git config --global user.name Devops
- run: npm version --no-git-tag-version ${{ github.event.release.tag_name }}
- run: npm i
- run: CI=false npm run build

- name: Build
run: |
set +e
CI=false npm run build 2>&1 | tee /tmp/build.log
BUILD_EXIT=${PIPESTATUS[0]}
set -e
if [ $BUILD_EXIT -ne 0 ] || grep -q "npm ERR!" /tmp/build.log; then
echo "::error::Build failed"
exit 1
fi

- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
with:
platforms: arm64,amd64


- name: Get role ARN
id: get_role
env:
ARN_JSON: ${{ secrets.AWS_ROLE_ARN }}
run: |
arn=$(echo "$ARN_JSON" | jq -r '.dev')
echo "::add-mask::$arn"
echo "arn=$arn" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::368076259134:role/github-actions-role
role-to-assume: ${{ steps.get_role.outputs.arn }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
Expand Down Expand Up @@ -106,13 +123,21 @@ jobs:
matrix:
service: ${{ fromJson(needs.Build.outputs.service) }}
steps:
- name: Get role ARN
id: get_role
env:
ARN_JSON: ${{ secrets.AWS_ROLE_ARN }}
run: |
arn=$(echo "$ARN_JSON" | jq -r '.prod')
echo "::add-mask::$arn"
echo "arn=$arn" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::471112828260:role/github-actions-role
role-to-assume: ${{ steps.get_role.outputs.arn }}
aws-region: us-east-1

- name: deploy
run: |
aws ecs update-service --cluster ${{ env.ECS_Cluster }} --service topia-${{ env.ENV }}-${{ matrix.service }}0 --force-new-deployment
aws ecs update-service --cluster ${{ env.ECS_Cluster }} --service topia-${{ env.ENV }}-${{ matrix.service }}0 --force-new-deployment

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/arm64 node:20.10-alpine3.19
FROM node:22-alpine
WORKDIR /app
ADD build ./build
ADD package* ./
Expand Down
24 changes: 21 additions & 3 deletions src/controllers/handleDropPiece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@ export const handleDropPiece = async (req: Request, res: Response) => {

const gameText = droppedAssets[0];
if (!shouldUpdateGame) {
if (gameText) await gameText.updateCustomTextAsset({}, text);
throw text;
if (gameText) {
await gameText.updateCustomTextAsset({}, text).catch((error) =>
errorHandler({
error,
functionName: "handleDropPiece",
message: "Error updating game text asset",
}),
);
}
await keyAsset.updateDataObject({ turnCount: turnCount + 1 });
return console.log("Drop piece invalid: ", text);
}

const promises = [];
Expand Down Expand Up @@ -196,7 +205,16 @@ export const handleDropPiece = async (req: Request, res: Response) => {
}

promises.push(keyAsset.updateDataObject(updatedData, { analytics }));
if (gameText) promises.push(gameText.updateCustomTextAsset({}, text));
if (gameText)
promises.push(
gameText.updateCustomTextAsset({}, text).catch((error) =>
errorHandler({
error,
functionName: "handleDropPiece",
message: "Error updating game text asset",
}),
),
);

await Promise.all(promises);
} catch (error) {
Expand Down
35 changes: 31 additions & 4 deletions src/controllers/handlePlayerSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@ export const handlePlayerSelection = async (req: Request, res: Response) => {
const playerText = droppedAssets.find((droppedAsset) => droppedAsset.uniqueName === `player${playerId}Text`);

if (!shouldUpdateGame) {
if (gameText) gameText.updateCustomTextAsset({}, text);
throw text;
if (gameText) {
await gameText.updateCustomTextAsset({}, text).catch((error) =>
errorHandler({
error,
functionName: "handlePlayerSelection",
message: "Error updating game text asset",
}),
);
}
await keyAsset.updateDataObject({ playerCount: playerCount + 1 });
return console.log("Player selection invalid: ", text);
}

const promises = [];
Expand All @@ -81,8 +90,26 @@ export const handlePlayerSelection = async (req: Request, res: Response) => {
},
),
);
if (playerText) promises.push(playerText.updateCustomTextAsset({}, username));
if (gameText) promises.push(gameText.updateCustomTextAsset({}, text));
if (playerText)
promises.push(
playerText.updateCustomTextAsset({}, username).catch((error) =>
errorHandler({
error,
functionName: "handlePlayerSelection",
message: "Error updating player text asset",
}),
),
);
if (gameText)
promises.push(
gameText.updateCustomTextAsset({}, text).catch((error) =>
errorHandler({
error,
functionName: "handlePlayerSelection",
message: "Error updating game text asset",
}),
),
);
await Promise.all(promises);
} catch (error) {
await keyAsset.updateDataObject({ playerCount: playerCount + 1 });
Expand Down
Loading