Skip to content

Commit

Permalink
github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
theshell76 committed Sep 19, 2024
1 parent ac5beeb commit 7d92e6d
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 101 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/devel-chart.yaml

This file was deleted.

58 changes: 0 additions & 58 deletions .github/workflows/devel-image.yaml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/publish-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish helm chart
run-name: Publish helm chart

on:
push:
tags: ["chart-*"]
branches: ['main', 'devel']
paths: ['chart/**']

env:
CHART_PATH: chart
UPDATE_DEPS: 'false'
# GitHub Container registry
GHCR_NAME: ${{ github.repository_owner }}/helm
# Docker Hub
# DHUB_NAME: insios-helm
# DHUB_USERNAME: ${{ secrets.INSIOS_DOCKER_USERNAME }}
# DHUB_PASSWORD: ${{ secrets.INSIOS_DOCKER_PASSWORD }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Helm
uses: azure/setup-helm@v4

- name: Extract metadata (chart name, tag)
id: meta
run: |
echo "name=$(helm show chart ${{ env.CHART_PATH }} | grep 'name:' | awk '{print $2}')" >> "$GITHUB_OUTPUT"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "tag=$(echo '${{ github.ref_name }}' | awk -F '-' '{print $2}')" >> "$GITHUB_OUTPUT"
else
echo "tag=0.0.0-${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
fi
- name: Build and push Helm chart to Container registry
uses: appany/helm-oci-chart-releaser@v0.4.2
with:
path: ${{ env.CHART_PATH }}
update_dependencies: '${{ env.UPDATE_DEPS }}'
name: ${{ steps.meta.outputs.name }}
tag: ${{ steps.meta.outputs.tag }}
registry: ghcr.io
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ env.GHCR_NAME }}

# - name: Build and push Helm chart to Docker Hub
# uses: appany/helm-oci-chart-releaser@v0.4.2
# with:
# path: ${{ env.CHART_PATH }}
# update_dependencies: '${{ env.UPDATE_DEPS }}'
# name: ${{ steps.meta.outputs.name }}
# tag: ${{ steps.meta.outputs.tag }}
# registry: registry-1.docker.io
# registry_username: ${{ env.DHUB_USERNAME }}
# registry_password: ${{ env.DHUB_PASSWORD }}
# repository: ${{ env.DHUB_NAME }}
72 changes: 72 additions & 0 deletions .github/workflows/publish-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish docker image
run-name: Publish docker image

on:
push:
tags: ["app-*"]
branches: ['main', 'devel']
paths: ['app/**']

env:
APP_PATH: app
# GitHub Container registry
GHCR_NAME: ${{ github.repository_owner }}/docker/${{ github.event.repository.name }}
# Docker Hub
DHUB_NAME: insios/${{ github.event.repository.name }}
DHUB_USERNAME: ${{ secrets.INSIOS_DOCKER_USERNAME }}
DHUB_PASSWORD: ${{ secrets.INSIOS_DOCKER_PASSWORD }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DHUB_USERNAME }}
password: ${{ env.DHUB_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.GHCR_NAME }}
${{ env.DHUB_NAME }}
tags: |
type=ref,event=branch
type=match,pattern=app-(\d+.\d+.\d+),group=1
type=match,pattern=app-(\d+.\d+),group=1
type=match,pattern=app-(\d+),group=1
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: ${{ APP_PATH }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ env.GHCR_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
1 change: 1 addition & 0 deletions app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
2 changes: 1 addition & 1 deletion Dockerfile → app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN ln -sf $APP_LIB/bin/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh && \
ln -sf /usr/bin/msmtp /usr/sbin/sendmail && \
ln -sf $APP_LIB/etc/msmtprc /etc/msmtprc

COPY app/ $APP_LIB
COPY ./ $APP_LIB

EXPOSE 587 586
ENTRYPOINT ["docker-entrypoint.sh"]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion charts/smarthost/Chart.yaml → chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ version: 0.0.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "devel"
appVersion: "latest"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions charts/chart-releaser.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions devel/bin/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ fi
if [ -z "$LOCAL_SUBMIT_PORT_PP" ]; then
LOCAL_SUBMIT_PORT_PP="8586"
fi
if [ -z "$HELM_CHART" ]; then
HELM_CHART="./chart"
fi
if [ -z "$HELM_NS" ]; then
HELM_NS="default"
fi
Expand Down
2 changes: 1 addition & 1 deletion devel/bin/helm-install
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ helm upgrade --install --atomic --cleanup-on-fail \
--namespace "$HELM_NS" --create-namespace \
$HELM_VALUES \
--set podAnnotations.rollme="$(date)" \
smarthost ./chart
smarthost $HELM_CHART
2 changes: 1 addition & 1 deletion devel/bin/helm-template
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

. ./devel/bin/config.sh helm

helm template smarthost ./chart $HELM_VALUES
helm template smarthost $HELM_CHART $HELM_VALUES

0 comments on commit 7d92e6d

Please sign in to comment.