Skip to content

Guilamb is building and deploying the app 🏗️ #21

Guilamb is building and deploying the app 🏗️

Guilamb is building and deploying the app 🏗️ #21

Workflow file for this run

name: Build and Deploy
run-name: ${{ github.actor }} is building and deploying the app 🏗️
on:
push:
# If we specify branches: [main] here it will run for any matching tags or push on branch main
tags: ['v[0-9].[0-9]+.[0-9]+']
workflow_dispatch:
permissions:
users:
- github.repository_owner
jobs:
build-musl:
runs-on: ubuntu-latest
# So we need to put the condition in the if here
if: ${{ (github.actor == github.event.repository.owner.login) && (github.ref == 'refs/heads/main') }}
steps:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- uses: actions/checkout@v3
- run: rustup target add x86_64-unknown-linux-musl
- name: Install musl build tools
run: sudo apt update && sudo apt install musl-tools -y
- name: Cargo build
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/guilamb/interspecies-reviewer:latest
ghcr.io/guilamb/interspecies-reviewer:${{ github.run_number }}
secrets: |
"github_token=${{ secrets.REGISTRY_TOKEN }}"
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build-musl
if: github.actor == github.event.repository.owner.login
steps:
- name: Set the Kubernetes context
uses: azure/k8s-set-context@v2
with:
method: service-account
k8s-url: ${{ secrets.SERVER_URL }}
k8s-secret: ${{ secrets.KUBERNETES_SECRET }}
- name: Checkout source code
uses: actions/checkout@v3
- name: Inject secret into manifest
run: awk -i inplace -v secret="${{ secrets.DISCORD_TOKEN }}" '{gsub("DISCORD_TOKEN_SECRET", secret)}1' kubernetes/deployment.yaml
- name: Deploy to the Kubernetes cluster
uses: azure/k8s-deploy@v1
with:
action: deploy
strategy: basic
namespace: interspecies-reviewer
manifests: |
kubernetes/deployment.yaml
images: |
ghcr.io/guilamb/interspecies-reviewer:latest
imagepullsecrets: |
github-container-registry