Skip to content

release-pipeline

release-pipeline #9

---
name: release-pipeline
permissions:
contents: write
on:
workflow_dispatch:
inputs:
package:
description: Name of the package that will be published
required: true
type: string
default: mailu
version:
description: Version of the package that will be published
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
outputs:
release_body: ${{ fromJSON(steps.get_release.outputs.data).body }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout Github Pages to gh-pages folder
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
ref: gh-pages
path: gh-pages
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Install dependencies
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm dependency build mailu
- name: Run helm lint
run: helm lint --strict --values mailu/ci/helm-lint-values.yaml mailu
- name: Install chart-releaser
uses: helm/[email protected]
with:
install_only: true
- name: Package Chart with chart-releaser
run: |
cr package mailu
- name: Get Release
uses: octokit/[email protected]
id: get_release
with:
route: GET /repos/{repo}/releases/tags/{tag}
repo: ${{ github.repository }}
tag: ${{ github.event.inputs.package }}-${{ github.event.inputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Chart build to Release
uses: softprops/action-gh-release@v1
with:
name: "${{ github.event.inputs.package }}: v${{ github.event.inputs.version }}"
tag_name: "${{ github.event.inputs.package }}-${{ github.event.inputs.version }}"
generate_release_notes: false
body: ${{ fromJSON(steps.get_release.outputs.data).body }}
files: |
.cr-release-packages/${{ github.event.inputs.package }}-${{ github.event.inputs.version }}.tgz
- name: Update chart index and publish to Github pages
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github actions"
REPO_NAME=$(echo "${{ github.repository }}" | cut -d "/" -f 2)
cr -t $GITHUB_TOKEN index -o ${{ github.repository_owner }} -r ${REPO_NAME} -i gh-pages/index.yaml --release-name-template "{{ .Name }}-{{ .Version }}"
cd gh-pages
git add .
git commit -m "New Chart Release for ${{ github.event.inputs.package }}: ${{ github.event.inputs.version }}"
git push origin gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-matrix:
needs:
- publish
runs-on: ubuntu-latest
name: Send message via Matrix
steps:
- name: Send message to mailu-helm-chart channel
# Only run this job if the release-please job created a release
id: matrix-chat-message
uses: fadenb/[email protected]
with:
homeserver: "matrix.org"
token: ${{ secrets.MATRIX_TOKEN }}
channel: "!KluZWhQwHDYrOfqJdD:make-it.fr"
message: |
# New release of ${{ github.event.inputs.package }} helm chart: ${{ github.event.inputs.version }}
[${{ github.event.inputs.version }}](https://github.com/${{ github.repository }}/releases/tag/${{ github.event.inputs.package }}-${{ github.event.inputs.version }}) has been released.
${{ needs.publish.outputs.release_body }}