Merge pull request #1448 from porter-dev/main #462
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push to production Helm chart repo | |
on: | |
push: | |
branches: [ production ] | |
jobs: | |
build: | |
environment: production | |
runs-on: ubuntu-latest | |
outputs: | |
addons-matrix: ${{ steps.addons-matrix.outputs.matrix }} | |
applications-matrix: ${{ steps.applications-matrix.outputs.matrix }} | |
ref: ${{ steps.auto-commit-action.outputs.commit_hash }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: azure/setup-helm@v3 | |
with: | |
version: 'v3.3.4' | |
- name: Install yq | |
run: | | |
wget https://github.com/mikefarah/yq/releases/download/v4.35.2/yq_linux_amd64 -O ./yq | |
chmod +x ./yq | |
sudo mv ./yq /usr/local/bin/yq | |
- name: Build modified application charts | |
run: | | |
./scripts/build.sh applications ${{ github.sha }} ${{ github.event.before }} | |
env: | |
CHARTMUSEUM_USERNAME: ${{ secrets.CHARTMUSEUM_USERNAME }} | |
CHARTMUSEUM_PASSWORD: ${{ secrets.CHARTMUSEUM_PASSWORD }} | |
CHARTMUSEUM_URL: ${{ secrets.CHARTMUSEUM_URL }} | |
- name: Build modified addon charts | |
run: | | |
./scripts/build.sh addons ${{ github.sha }} ${{ github.event.before }} | |
env: | |
CHARTMUSEUM_USERNAME: ${{ secrets.CHARTMUSEUM_ADDON_USERNAME }} | |
CHARTMUSEUM_PASSWORD: ${{ secrets.CHARTMUSEUM_ADDON_PASSWORD }} | |
CHARTMUSEUM_URL: ${{ secrets.CHARTMUSEUM_ADDON_URL }} | |
- name: Set matrix for applications publishing | |
id: applications-matrix | |
run: | | |
matrix="$(git diff --name-only ${{ github.sha }} ${{ github.event.before }} | cut -f1,2,3 -d'/' | xargs -n 1 dirname | uniq | grep "applications/" | jq --compact-output --monochrome-output --raw-input --slurp 'split("\n") | map(select(. != ""))')" | |
if [[ "$matrix" == "[]" ]]; then | |
matrix='["null-chart"]' | |
fi | |
variable="{\"index\":$matrix}" | |
echo "matrix=$variable" >> $GITHUB_OUTPUT | |
- name: Set matrix for addons publishing | |
id: addons-matrix | |
run: | | |
matrix="$(git diff --name-only ${{ github.sha }} ${{ github.event.before }} | cut -f1,2,3 -d'/' | xargs -n 1 dirname | uniq | grep "addons/" | jq --compact-output --monochrome-output --raw-input --slurp 'split("\n") | map(select(. != ""))')" | |
if [[ "$matrix" == "[]" ]]; then | |
matrix='["null-chart"]' | |
fi | |
variable="{\"index\": $matrix}" | |
echo "matrix=$variable" >> $GITHUB_OUTPUT | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
id: auto-commit-action | |
with: | |
commit_message: Update Chart.yaml versions | |
commit_options: '--allow-empty' | |
file_pattern: "*/*/Chart.yaml" | |
commit_user_name: portersupport | |
commit_user_email: support@porter.run | |
publish-addons: | |
environment: production | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.build.outputs.addons-matrix)}} | |
steps: | |
- name: Checkout porter-charts | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.build.outputs.ref }} | |
- name: Update remote chart | |
uses: ./.github/actions/publish-chart | |
if: ${{ matrix.index != 'null-chart' }} | |
with: | |
chart_path: ${{ matrix.index }} | |
chartmuseum_username: ${{ secrets.CHARTMUSEUM_ADDON_USERNAME }} | |
chartmuseum_password: ${{ secrets.CHARTMUSEUM_ADDON_PASSWORD }} | |
chartmuseum_url: ${{ secrets.CHARTMUSEUM_ADDON_URL }} | |
publish-applications: | |
environment: production | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: ${{fromJson(needs.build.outputs.applications-matrix)}} | |
steps: | |
- name: Checkout porter-charts | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.build.outputs.ref }} | |
- name: Update remote chart | |
uses: ./.github/actions/publish-chart | |
if: ${{ matrix.index != 'null-chart' }} | |
with: | |
chart_path: ${{ matrix.index }} | |
chartmuseum_username: ${{ secrets.CHARTMUSEUM_USERNAME }} | |
chartmuseum_password: ${{ secrets.CHARTMUSEUM_PASSWORD }} | |
chartmuseum_url: ${{ secrets.CHARTMUSEUM_URL }} |