Skip to content

Revert "Exclude openapi files from builds + revert last commit" #796

Revert "Exclude openapi files from builds + revert last commit"

Revert "Exclude openapi files from builds + revert last commit" #796

Workflow file for this run

name: deploy bot stack
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
on:
push: { branches: [main] }
jobs:
deploy:
permissions:
contents: read
id-token: write
runs-on: ubuntu-24.04-arm
container: swift:6.3-noble
env:
IMAGE_TAG: ${{ github.sha }}
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@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
with:
role-to-assume: ${{ vars.PENNY_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
run: |
if docker buildx imagetools inspect "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" > /dev/null 2>&1; then
echo "Image $ECR_REPOSITORY:$IMAGE_TAG already exists, skipping build and push."
exit 0
fi
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
- name: Setup mise
uses: jdx/mise-action@f10502fc09dadecfefb962fff68ce77213930204 # v4.2.2
- name: Terraform init
working-directory: infra
env:
# A hack to skip using a profile in CI, to use OIDC instead
TF_VAR_aws_profile: ""
run: |
terraform init -input=false -backend-config="profile="
- name: Terraform apply
working-directory: infra
env:
# A hack to skip using a profile in CI, to use OIDC instead
TF_VAR_aws_profile: ""
TF_VAR_penny_image_tag: ${{ env.IMAGE_TAG }}
run: |
terraform apply -input=false -auto-approve