Skip to content

Using separate PAT for publishing helm chart #17

Using separate PAT for publishing helm chart

Using separate PAT for publishing helm chart #17

Workflow file for this run

name: OSTicket CI/CD Pipeline
on:
push:
branches:
- develop
- release/*
- feature/*
pull_request:
branches: [develop]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-fpm:
name: Build and Push FPM
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-fpm
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=long
type=ref,event=branch
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64,amd64"
- name: Build and push PHP-FPM Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: production
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=build-php
cache-to: type=gha,scope=build-php,mode=max
build-args: |
VERSION=${{ github.sha }}
# - name: Run Trivy vulnerability scanner
# uses: aquasecurity/trivy-action@v1
# with:
# image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
# format: 'sarif'
# output: 'trivy-results.sarif'
# - name: Upload Trivy scan results
# uses: github/codeql-action/upload-sarif@v3
# if: always()
# with:
# sarif_file: 'trivy-results.sarif'
build-and-push-nginx:
name: Build and Push Nginx
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-nginx
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=long
type=ref,event=branch
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "arm64,amd64"
- name: Build and push Nginx Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}-nginx
labels: ${{ steps.meta.outputs.labels }}
target: nginx
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=build-nginx
cache-to: type=gha,scope=build-nginx,mode=max
build-args: |
VERSION=${{ github.sha }}
package-helm-chart:
name: Package Helm Chart
runs-on: ubuntu-latest
needs: [build-and-push-fpm, build-and-push-nginx]
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set environment variables
id: set-variables
run: |
echo "REPOSITORY=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
echo "VERSION=$(yq -r .version ./kubernetes/charts/osticket/Chart.yaml)" >> "$GITHUB_OUTPUT"
- name: Env variable output
id: test-variables
run: |
echo ${{ steps.set-variables.outputs.REPOSITORY }}
echo ${{ steps.set-variables.outputs.VERSION }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Package and push helm chart
run: |
helm package ./kubernetes/charts/osticket --version ${{ steps.set-variables.outputs.VERSION }}
helm push ./osticket-${{ steps.set-variables.outputs.VERSION }}.tgz oci://${{ steps.set-variables.outputs.REPOSITORY }}/charts
publish-helm-chart:
name: Publish Helm Chart
runs-on: ubuntu-latest
needs: [package-helm-chart]
permissions:
id-token: write
packages: write
contents: write
actions: read
deployments: read
pull-requests: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Publish Helm chart to GitHub Pages
uses: stefanprodan/helm-gh-pages@0ad2bb377311d61ac04ad9eb6f252fb68e207260 # v1.7.0
with:
token: ${{ secrets.GHA_HELM_PAT }}
# linting: off
charts_dir: ./kubernetes/charts
repository: helm-charts
branch: gh-pages
# target_dir: charts