gha cache #85
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: π« CI (Stablecog Website) | |
on: | |
push: | |
branches: [master] | |
concurrency: | |
group: environment-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
discord_notification_build_started: | |
name: π‘ Discord Notification (Build Started) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Environment Variables | |
uses: ./.github/actions/setup-env | |
id: setup-env | |
- name: Send Discord Webhook | |
uses: ./.github/actions/discord-webhook | |
with: | |
webhook-url: ${{ secrets.DISCORD_WEBHOOK }} | |
embed-color: 16776960 | |
embed-title: '[sc-web] ${{ steps.setup-env.outputs.COMMIT_MSG }} β’ ${{ steps.setup-env.outputs.SHORT_SHA }}' | |
embed-description: '```Build Started```' | |
build_amd64: | |
name: π¨ Build Docker Image (amd64) | |
runs-on: warp-ubuntu-latest-x64-2x | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Environment Variables | |
uses: ./.github/actions/setup-env | |
id: setup-env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }}-amd64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
provenance: false | |
build_arm64: | |
name: π¨ Build Docker Image (arm64) | |
runs-on: warp-ubuntu-latest-arm64-2x | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Environment Variables | |
uses: ./.github/actions/setup-env | |
id: setup-env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/arm64 | |
push: true | |
tags: stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }}-arm64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
provenance: false | |
create_and_push_manifest: | |
name: π·οΈ Create and Push Multi-architecture Manifest | |
needs: [build_amd64, build_arm64] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Environment Variables | |
uses: ./.github/actions/setup-env | |
id: setup-env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create and Push Multi-Arch Manifest | |
run: | | |
docker buildx imagetools create -t stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }} \ | |
stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }}-amd64 \ | |
stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }}-arm64 | |
- name: Tag and Push 'latest' | |
run: | | |
docker buildx imagetools create -t stablecog/sc-web:latest \ | |
stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }}-amd64 \ | |
stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }}-arm64 | |
deploy: | |
name: π Deploy Stablecog Website | |
needs: [create_and_push_manifest] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Environment Variables | |
uses: ./.github/actions/setup-env | |
id: setup-env | |
- name: Deploy | |
uses: ./.github/actions/k3s-deploy | |
with: | |
image: stablecog/sc-web:${{ steps.setup-env.outputs.BRANCH_NAME }}-${{ steps.setup-env.outputs.SHORT_SHA }} | |
embed-title: '${{ steps.setup-env.outputs.COMMIT_MSG }} β’ ${{ steps.setup-env.outputs.SHORT_SHA }}' | |
webhook-url: ${{ secrets.DISCORD_WEBHOOK }} | |
kube_config: ${{ secrets.K3S_KUBE_CONFIG }} |