Skip to content

Commit

Permalink
feat: use checked in OCELOT_VERSION
Browse files Browse the repository at this point in the history
`workflow_dispatch` only works on the default branch which is inconvenient for development
  • Loading branch information
roschaefer committed Oct 28, 2024
1 parent 57e7615 commit 78e7f7b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OCELOT_VERSION=sha-80ff4ef
34 changes: 12 additions & 22 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
name: publish

on:
workflow_dispatch:
inputs:
ocelot_version:
description: Ocelot build image version
required: true
type: string
deploy:
description: Deploy to cluster
required: true
type: boolean
on: push

jobs:
build-and-push-images:
Expand Down Expand Up @@ -42,19 +32,21 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Read $OCELOT_VERSION from file
run: cat .env >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@70b2cdc6480c1a8b86edf1777157f8f437de2166
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule,prefix=ocelot-${{ inputs.ocelot_version }}--branded-
type=semver,pattern={{version}},prefix=ocelot-${{ inputs.ocelot_version }}--branded-
type=semver,pattern={{major}}.{{minor}},prefix=ocelot-${{ inputs.ocelot_version }}--branded-
type=semver,pattern={{major}},prefix=ocelot-${{ inputs.ocelot_version }}--branded-
type=ref,event=branch,prefix=ocelot-${{ inputs.ocelot_version }}--branded-
type=ref,event=pr,prefix=ocelot-${{ inputs.ocelot_version }}--branded-
type=sha,prefix=ocelot-${{ inputs.ocelot_version }}--branded-sha-
type=schedule,prefix=ocelot-${{ env.OCELOT_VERSION }}--branded-
type=semver,pattern={{version}},prefix=ocelot-${{ env.OCELOT_VERSION }}--branded-
type=semver,pattern={{major}}.{{minor}},prefix=ocelot-${{ env.OCELOT_VERSION }}--branded-
type=semver,pattern={{major}},prefix=ocelot-${{ env.OCELOT_VERSION }}--branded-
type=ref,event=branch,prefix=ocelot-${{ env.OCELOT_VERSION }}--branded-
type=ref,event=pr,prefix=ocelot-${{ env.OCELOT_VERSION }}--branded-
type=sha,prefix=ocelot-${{ env.OCELOT_VERSION }}--branded-sha-
- name: Build and push Docker images
id: push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
Expand All @@ -63,13 +55,13 @@ jobs:
context: .
push: true
build-args: |
OCELOT_VERSION=${{ inputs.ocelot_version }}
OCELOT_VERSION=${{ env.OCELOT_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy-to-kubernetes:
runs-on: ubuntu-latest
if: ${{ inputs.deploy }}
if: ${{ github.ref == 'refs/tags/staging' }}
needs: build-and-push-images
steps:
- uses: mdgreenwald/mozilla-sops-action@d9714e521cbaecdae64a89d2fdd576dd2aa97056 # v1.6.0
Expand All @@ -84,8 +76,6 @@ jobs:
sops decrypt ./helmfile/secrets/kubeconfig > ~/.kube/config
chmod 600 ~/.kube/config
- uses: helmfile/helmfile-action@80fbb6408b98822310f94d8d1321a2cacf87f78f #v1.9.2
env:
OCELOT_IMAGE_TAG: ${{ inputs.ocelot_version }}
with:
helmfile-args: apply
helmfile-workdirectory: ./helmfile
Expand Down
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions helmfile/environments/default.yaml.gotmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ $branded_image_tag:= env "BRANDED_IMAGE_TAG" | default (exec "../scripts/image_tag.sh" (list) | trim) }}
{{ $ocelot_image_tag := env "OCELOT_IMAGE_TAG" | default "master" }}
{{ $branded_image_tag:= env "BRANDED_IMAGE_TAG" | default (exec "../scripts/branded_image_tag.sh" (list) | trim) }}
{{ $ocelot_image_tag := env "OCELOT_IMAGE_TAG" | default (exec "../scripts/ocelot_image_tag.sh" (list) | trim) }}

domain: staging.ocelot-social.roschaefer.de
namespace: ocelot-staging
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions helmfile/scripts/ocelot_image_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)

set -a; . ${SCRIPT_DIR}/../../.env; set +a;
echo $OCELOT_VERSION

0 comments on commit 78e7f7b

Please sign in to comment.