feat(gha): release only changed charts to s3 #7
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: Release changed charts to S3 | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- charts/** | |
types: | |
- opened | |
- synchronize | |
- closed | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
generate-matrix: | |
outputs: | |
list: ${{ steps.list.outputs.list }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v40 | |
with: | |
dir_names: true | |
dir_names_exclude_current_dir: true | |
dir_names_max_depth: 2 | |
- name: Show changes | |
run: | | |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | |
echo "$file was changed" | |
done | |
echo ${{ steps.changed-files.outputs.all_changed_files }} | tr " " "\n" | grep charts | xargs -n 1 basename | tr "\n" " " | jq -R -s -c 'split(" ")[:-1]' > res.json | |
echo "list<<EOF" >> $GITHUB_OUTPUT | |
cat res.json >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
template: | |
runs-on: ubuntu-latest | |
needs: | |
- generate-matrix | |
strategy: | |
matrix: | |
chart: ${{ fromJson(needs.generate-matrix.outputs.list) }} | |
defaults: | |
run: | |
working-directory: charts/${{ matrix.chart }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update dependencies | |
run: helm dependency update | |
- name: Helm template | |
run: helm template . | |
# package: | |
# runs-on: ubuntu-latest | |
# needs: | |
# - generate-matrix | |
# strategy: | |
# matrix: | |
# chart: ${{ fromJson(needs.generate-matrix.outputs.list) }} | |
# defaults: | |
# run: | |
# working-directory: charts/${{ matrix.chart }} | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - uses: azure/setup-helm@v3 | |
# with: | |
# version: v3.12.3 | |
# - name: Update dependencies | |
# run: helm dependency update | |
# - name: Helm package | |
# run: helm package . | |
# - name: Get package name | |
# id: file | |
# run: echo name=$(ls | grep .tgz) >> $GITHUB_OUTPUT | |
# - name: Upload package | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: ${{ matrix.chart }} | |
# path: charts/${{ matrix.chart }}/${{ steps.file.outputs.name }} | |
# retention-days: 1 | |
# release: | |
# env: | |
# HELM_S3_MODE: 3 | |
# runs-on: ubuntu-latest | |
# needs: | |
# - generate-matrix | |
# - package | |
# - template | |
# strategy: | |
# matrix: | |
# chart: ${{ fromJson(needs.generate-matrix.outputs.list) }} | |
# steps: | |
# - name: Configure AWS credentials | |
# uses: aws-actions/configure-aws-credentials@v2 | |
# with: | |
# role-to-assume: arn:aws:iam::506534868111:role/oidc/helm-s3 | |
# role-session-name: helm-s3-${{ github.run_id }} | |
# aws-region: eu-central-1 | |
# - uses: azure/setup-helm@v3 | |
# with: | |
# version: v3.12.3 | |
# - name: Install Helm S3 Plugin | |
# run: helm plugin install https://github.com/hypnoglow/helm-s3.git --version 0.14.0 | |
# - name: Add Helm repo | |
# run: helm repo add mys3 s3://windkube-charts/charts | |
# - name: Download package | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: ${{ matrix.chart }} | |
# - name: Get package name | |
# id: file | |
# run: | | |
# pwd | |
# ls | |
# echo name=$(ls | grep .tgz) >> $GITHUB_OUTPUT | |
# - name: Push chart | |
# run: helm s3 push ./${{ steps.file.outputs.name }} mys3 --ignore-if-exists |