All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m58s
53 lines
1.5 KiB
YAML
53 lines
1.5 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker BuildX
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Docker login
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.REGISTRY_URL }}
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Get Meta
|
|
id: meta
|
|
run: |
|
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
|
echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ vars.REGISTRY_URL }}/${{ steps.meta.outputs.REPO_NAME }}:${{ github.sha }}
|
|
${{ vars.REGISTRY_URL }}/${{ steps.meta.outputs.REPO_NAME }}:latest
|
|
|
|
- name: Set up kubectl
|
|
uses: azure/setup-kubectl@v3
|
|
|
|
- name: Deploy to cluster
|
|
env:
|
|
KUBECONFIG: /tmp/kubeconfig.yaml
|
|
NAMESPACE: ayaume
|
|
APP: ${{ steps.meta.outputs.REPO_NAME }}
|
|
IMAGE: ${{ vars.REGISTRY_URL }}/${{ steps.meta.outputs.REPO_NAME }}:${{ github.sha }}
|
|
shell: bash
|
|
run: |
|
|
echo "${{ secrets.KUBE_CONFIG }}" > $KUBECONFIG
|
|
kubectl -n $NAMESPACE set image deployment/$APP $APP=$IMAGE
|