Skip to content

Fixes for supporting previous major versions (#397) #767

Fixes for supporting previous major versions (#397)

Fixes for supporting previous major versions (#397) #767

Workflow file for this run

name: deploy bot stack
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push: { branches: [main] }
jobs:
deploy:
permissions:
contents: read
id-token: write
runs-on: ubuntu-24.04-arm
container: swift:6.3-noble
steps:
- name: Checkout
uses: actions/checkout@v7
# actions/cache will detect zstd and will become much faster. curl for docker installation.
- name: Install zstd
run: |
apt-get update -y
apt-get install -y curl zstd
- name: Restore/Cache .build
if: ${{ runner.debug != '1' }}
id: "restore-cache"
uses: actions/cache@v6
with:
path: .build
key: "penny-release-static-build-${{ runner.os }}-${{ github.event.after }}"
restore-keys: "penny-release-static-build-${{ runner.os }}-"
- name: Build Penny
run: |
apt-get update -y
apt-get install -y libjemalloc-dev
swift build \
--product Penny \
-c release \
--force-resolved-versions \
--static-swift-stdlib \
-Xlinker -ljemalloc
- name: Install Docker
run: curl -fsSL https://get.docker.com | bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6.2.0
with:
role-to-assume: ${{ vars.OIDC_ROLE_ARN }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@d539f0932e70871a027e9d5a9d8fc38589180a64 # v2.1.6
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: penny-bot-discord-image
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile . \
--build-arg SWIFT_CONFIGURATION=release \
--build-arg EXEC_NAME=Penny
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@6853cfae8c3a7d978fbf68b5a55453395541dfbb # v1.8.5
with:
task-definition: ./deploy/penny-discord-bot-task.json
container-name: penny-bot
image: ${{ steps.build-image.outputs.image }}
- name: Deploy to Amazon ECS Service
id: task-dep
uses: aws-actions/amazon-ecs-deploy-task-definition@a310a830f5c14e583e35d84e4e1ec7dd177c3c9c # v2.6.2
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
wait-for-service-stability: true
- name: Deploy to AWS cloudformation
uses: aws-actions/aws-cloudformation-github-deploy@81e3b03d2266bcb76c4bcc37a7d71d9cb67838bb # v2.2.0
with:
name: penny-discord-bot-stack
template: ./deploy/penny-discord-bot-stack.yml
parameter-overrides: >-
TaskDefinition=${{ steps.task-dep.outputs.task-definition-arn }}