ws4kp/.github/workflows/build-deploy.yaml

68 lines
2.2 KiB
YAML
Raw Normal View History

2023-04-13 17:43:52 +00:00
name: cd
on: push
env:
DEPLOYMENT: weatherstar
YAMLPATH: clusters/home-kluster/apps/weatherstar/weatherstar/app/deployment.yaml
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- id: short-sha
uses: benjlevesque/short-sha@v1.2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/rmitchellscott/ws4kp
tags: |
type=raw,priority=1000,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=branch
${{ steps.short-sha.outputs.sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
pull: true
push: ${{ github.ref == 'refs/heads/main' }}
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# deploy:
# runs-on: ubuntu-latest
# name: Deploy to flux
# needs: build
# steps:
# - name: Check out Kubernetes repo
# uses: actions/checkout@v3
# with:
# repository: rmitchellscott/kubernetes-apps
# token: ${{ secrets.PAT }}
# - id: short-sha
# uses: benjlevesque/short-sha@v1.2
# - name: Replace the image tag
# env:
# TAG: ${{ steps.short-sha.outputs.sha }}
# run: yq -i e '(select(.kind=="Deployment" and .metadata.name==env(DEPLOYMENT)) | .spec.template.spec.containers.[].image) |= split(":").0 + ":" + env(TAG)' $YAMLPATH
# - name: Commit and push
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: Update image tag for ${{env.DEPLOYMENT}} to ${{ steps.short-sha.outputs.sha }}