|
| 1 | +name: 'Sync Helm chart from release using tar file' |
| 2 | +description: 'Download and sync a Helm chart from a release URL' |
| 3 | + |
| 4 | +inputs: |
| 5 | + chart_url: |
| 6 | + description: 'Full URL to the chart .tgz file' |
| 7 | + required: true |
| 8 | + target_directory: |
| 9 | + description: 'Directory within the current repo where we would like to copy the files' |
| 10 | + required: true |
| 11 | + github_token: |
| 12 | + description: 'Github token to use for API calls' |
| 13 | + required: true |
| 14 | + chart_name: |
| 15 | + description: 'Name of the chart for PR title and branch name' |
| 16 | + required: true |
| 17 | + |
| 18 | +runs: |
| 19 | + using: composite |
| 20 | + steps: |
| 21 | + - name: Create temp directory |
| 22 | + shell: bash |
| 23 | + run: mkdir -p /tmp/helm-charts |
| 24 | + - name: Download Helm chart |
| 25 | + shell: bash |
| 26 | + run: | |
| 27 | + echo "Downloading chart from: ${{ inputs.chart_url }}" |
| 28 | + curl -L -o /tmp/helm-charts/chart.tgz "${{ inputs.chart_url }}" |
| 29 | + - name: Extract chart |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + cd /tmp/helm-charts |
| 33 | + tar -xzf chart.tgz |
| 34 | + - name: Sync to target directory |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + # Create target directory if it doesn't exist |
| 38 | + mkdir -p ${{ inputs.target_directory }} |
| 39 | +
|
| 40 | + # Copy contents to directory |
| 41 | + rsync -av --delete --cvs-exclude /tmp/helm-charts/${{ inputs.chart_name }}/ ${{ inputs.target_directory }}/ |
| 42 | + |
| 43 | + # Add to vendored-charts |
| 44 | + echo "${{ inputs.target_directory }}" >> vendored-charts |
| 45 | + sort -uo vendored-charts vendored-charts |
| 46 | +
|
| 47 | + - name: Create PR |
| 48 | + uses: peter-evans/create-pull-request@v5 |
| 49 | + with: |
| 50 | + token: ${{ inputs.github_token }} |
| 51 | + add-paths: | |
| 52 | + vendored-charts |
| 53 | + ${{ inputs.target_directory }} |
| 54 | + title: "Sync: ${{ inputs.chart_name }} from tar file" |
| 55 | + branch: "sync-${{ inputs.chart_name }}-release" |
| 56 | + |
| 57 | + - name: Cleanup |
| 58 | + shell: bash |
| 59 | + run: rm -rf /tmp/helm-charts |
0 commit comments