Update build.yml #399
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
env: | |
REGISTRY: 289115055556.dkr.ecr.us-east-1.amazonaws.com | |
IMAGE_NAME: wet-toast-talk-radio | |
IMAGE_NAME_GPU: wet-toast-talk-radio-gpu | |
DOCKER_BUILDKIT: 1 | |
jobs: | |
release: | |
name: Release Please | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: write | |
pull-requests: write | |
outputs: | |
release_created: ${{ steps.release-please.outputs.release_created }} | |
tag_name: ${{ steps.release-please.outputs.tag_name }} | |
major: ${{ steps.release-please.outputs.major }} | |
minor: ${{ steps.release-please.outputs.minor}} | |
steps: | |
- uses: google-github-actions/release-please-action@v3 | |
id: release-please | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
release-type: python | |
bump-minor-pre-major: true | |
bump-patch-for-minor-pre-major: true | |
docker-build: | |
name: Docker Build | |
runs-on: ubuntu-latest | |
needs: [release] | |
if: ${{ needs.release.outputs.release_created }} | |
permissions: | |
contents: read | |
packages: write | |
actions: read | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Turnstyle | |
uses: softprops/turnstyle@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Docker Build | |
run: | | |
docker build --target=prod -t wettoast . | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::289115055556:role/GitHubActionsWetToastTalkRadio | |
aws-region: us-east-1 | |
- name: Docker Push to ECR | |
run: | | |
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ env.REGISTRY }} | |
docker tag wettoast:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:commit-$GITHUB_SHA | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:commit-$GITHUB_SHA | |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:commit-$GITHUB_SHA ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.tag_name }} | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.tag_name }} | |
gpu-docker-build: | |
name: GPU Docker Build | |
runs-on: ubuntu-latest | |
needs: [release] | |
if: ${{ needs.release.outputs.release_created }} | |
permissions: | |
contents: read | |
packages: write | |
actions: read | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Turnstyle | |
uses: softprops/turnstyle@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Docker Build | |
run: | | |
docker build --target=prod-gpu -t wettoast-gpu . | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::289115055556:role/GitHubActionsWetToastTalkRadio | |
aws-region: us-east-1 | |
- name: Docker Push to ECR | |
run: | | |
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ env.REGISTRY }} | |
docker tag wettoast-gpu:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:commit-$GITHUB_SHA | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:commit-$GITHUB_SHA | |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:commit-$GITHUB_SHA ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:latest | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:latest | |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:${{ needs.release.outputs.tag_name }} | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_GPU }}:${{ needs.release.outputs.tag_name }} | |
deploy-release: | |
name: Deploy New Release | |
runs-on: ubuntu-latest | |
needs: [release, docker-build, gpu-docker-build] | |
if: ${{ needs.release.outputs.release_created }} | |
permissions: | |
contents: write | |
packages: write | |
actions: read | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Turnstyle | |
uses: softprops/turnstyle@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::289115055556:role/GitHubActionsWetToastTalkRadio | |
aws-region: us-east-1 | |
# - name: NPM Install | |
# working-directory: aws | |
# run: | | |
# npm ci | |
# npx clear-npx-cache | |
# - name: Deploy | |
# working-directory: aws | |
# run: | | |
# npx aws-cdk deploy WetToastTalkShowStack -c stack-name=WetToastTalkShowStack --parameters ImageTag=${{ needs.release.outputs.tag_name }} |