diff --git a/.github/workflows/push.yml b/.github/workflows/publish.yml similarity index 69% rename from .github/workflows/push.yml rename to .github/workflows/publish.yml index 20c4576..f7a6f43 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,16 @@ name: publish -on: push +on: + workflow_dispatch: + inputs: + ocelot_version: + description: Ocelot build image version + required: true + type: string + deploy: + description: Deploy to cluster + required: true + type: boolean jobs: build-and-push-images: @@ -38,13 +48,13 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=schedule - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=ref,event=branch - type=ref,event=pr - type=sha + 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- - name: Build and push Docker images id: push uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 @@ -53,13 +63,13 @@ jobs: context: . push: true build-args: | - OCELOT_VERSION=hetzner + OCELOT_VERSION=${{ inputs.ocelot_version }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} deploy-to-kubernetes: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/staging' + if: ${{ inputs.deploy }} needs: build-and-push-images steps: - uses: mdgreenwald/mozilla-sops-action@d9714e521cbaecdae64a89d2fdd576dd2aa97056 # v1.6.0 @@ -73,7 +83,7 @@ jobs: mkdir -p ~/.kube sops decrypt ./helmfile/secrets/kubeconfig > ~/.kube/config chmod 600 ~/.kube/config - # - run: echo "IMAGE_TAG=sha-$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV + - run: echo "IMAGE_TAG=ocelot-${{ inputs.ocelot_version }}--branded-sha-$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV - uses: helmfile/helmfile-action@80fbb6408b98822310f94d8d1321a2cacf87f78f #v1.9.2 with: helmfile-args: apply --environment staging diff --git a/docker/backend.Dockerfile b/docker/backend.Dockerfile index e152205..5e5fbda 100644 --- a/docker/backend.Dockerfile +++ b/docker/backend.Dockerfile @@ -1,6 +1,6 @@ ARG OCELOT_VERSION=master -FROM ghcr.io/ocelot-social-community/ocelot-social/backend:${OCELOT_VERSION}-code AS build +FROM ghcr.io/ocelot-social-community/ocelot-social/backend-build:${OCELOT_VERSION} AS build -FROM ghcr.io/ocelot-social-community/ocelot-social/backend:${OCELOT_VERSION}-base AS branded +FROM ghcr.io/ocelot-social-community/ocelot-social/backend-base:${OCELOT_VERSION} AS branded COPY --from=build /build . diff --git a/docker/maintenance.Dockerfile b/docker/maintenance.Dockerfile index 32ae532..b471bbd 100644 --- a/docker/maintenance.Dockerfile +++ b/docker/maintenance.Dockerfile @@ -1,7 +1,7 @@ ARG OCELOT_VERSION=master -FROM ghcr.io/ocelot-social-community/ocelot-social/maintenance:${OCELOT_VERSION}-code AS build +FROM ghcr.io/ocelot-social-community/ocelot-social/maintenance-build:${OCELOT_VERSION} AS build -FROM nginx:alpine AS branded +FROM ghcr.io/ocelot-social-community/ocelot-social/maintenance-base:${OCELOT_VERSION} AS branded COPY --from=build ./app/dist/ /usr/share/nginx/html/ COPY --from=build ./app/maintenance/nginx/custom.conf /etc/nginx/conf.d/default.conf diff --git a/docker/webapp.Dockerfile b/docker/webapp.Dockerfile index e4abd38..1a6b024 100644 --- a/docker/webapp.Dockerfile +++ b/docker/webapp.Dockerfile @@ -1,6 +1,6 @@ ARG OCELOT_VERSION=master -FROM ghcr.io/ocelot-social-community/ocelot-social/webapp:${OCELOT_VERSION}-code AS build +FROM ghcr.io/ocelot-social-community/ocelot-social/webapp-build:${OCELOT_VERSION} AS build -FROM ghcr.io/ocelot-social-community/ocelot-social/webapp:${OCELOT_VERSION}-base AS branded +FROM ghcr.io/ocelot-social-community/ocelot-social/webapp-base:${OCELOT_VERSION} AS branded COPY --from=build /build . diff --git a/helmfile/environments/default.yaml.gotmpl b/helmfile/environments/default.yaml.gotmpl deleted file mode 100644 index 86a316d..0000000 --- a/helmfile/environments/default.yaml.gotmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{ $image_tag:= env "IMAGE_TAG" | default (exec "../scripts/image_tag.sh" (list) | trim) }} - -domain: ocelot-social.roschaefer.de -namespace: ocelot-staging -image_tag: {{ $image_tag }} diff --git a/helmfile/environments/staging.yaml.gotmpl b/helmfile/environments/staging.yaml.gotmpl index 86a316d..cc64193 100644 --- a/helmfile/environments/staging.yaml.gotmpl +++ b/helmfile/environments/staging.yaml.gotmpl @@ -1,5 +1,3 @@ -{{ $image_tag:= env "IMAGE_TAG" | default (exec "../scripts/image_tag.sh" (list) | trim) }} - -domain: ocelot-social.roschaefer.de +domain: staging.ocelot-social.roschaefer.de namespace: ocelot-staging -image_tag: {{ $image_tag }} +image_tag: {{ requiredEnv "IMAGE_TAG" }} diff --git a/helmfile/helmfile.yaml.gotmpl b/helmfile/helmfile.yaml.gotmpl index 34e6f84..b1022f5 100644 --- a/helmfile/helmfile.yaml.gotmpl +++ b/helmfile/helmfile.yaml.gotmpl @@ -1,18 +1,12 @@ --- environments: - default: - values: - - ./environments/default.yaml.gotmpl staging: values: - ./environments/staging.yaml.gotmpl - production: - values: - - ./environments/production.yaml.gotmpl --- repositories: - name: ocelot-social - url: git+https://github.com/Ocelot-Social-Community/Ocelot-Social@deployment/hetzner/helmfile/ocelot-social?ref=hetzner + url: git+https://github.com/Ocelot-Social-Community/Ocelot-Social@deployment/helm/chart?ref=hetzner apiVersions: - monitoring.coreos.com/v1 diff --git a/helmfile/scripts/image_tag.sh b/helmfile/scripts/image_tag.sh deleted file mode 100755 index f921945..0000000 --- a/helmfile/scripts/image_tag.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -echo "sha-$(git rev-parse HEAD | cut -c 1-7)"