|
| 1 | +name: Sync Local Path Provisioner Chart |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Runs once a week, every Monday at 00:00 UTC |
| 6 | + - cron: '0 0 * * 1' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + sync-and-pr: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + ref: master |
| 17 | + |
| 18 | + - name: Checkout the upstream repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + repository: rancher/local-path-provisioner |
| 22 | + ref: master |
| 23 | + path: upstream |
| 24 | + |
| 25 | + - name: Extract upstream version |
| 26 | + id: version-extract |
| 27 | + run: | |
| 28 | + UPSTREAM_VERSION=$(cat upstream/deploy/chart/local-path-provisioner/Chart.yaml | grep 'version:' | awk '{print $2}') |
| 29 | + echo "Upstream version: $UPSTREAM_VERSION" |
| 30 | + echo "$UPSTREAM_VERSION=$UPSTREAM_VERSION" >> $GITHUB_ENV |
| 31 | +
|
| 32 | + - name: Check if the checked out version is different from current one |
| 33 | + id: version-check |
| 34 | + run: | |
| 35 | + if [ -f "./charts/local-path-provisioner/Chart.yaml" ]; then |
| 36 | + CURRENT_VERSION=$(cat charts/local-path-provisioner/Chart.yaml | grep 'version:' | awk '{print $2}') |
| 37 | + echo "Current version: $CURRENT_VERSION" |
| 38 | + |
| 39 | + if [ "$CURRENT_VERSION" != "${{ env.UPSTREAM_VERSION }}" ]; then |
| 40 | + echo "version_changed=true" >> $GITHUB_ENV |
| 41 | + else |
| 42 | + echo "version_changed=false" >> $GITHUB_ENV |
| 43 | + fi |
| 44 | + else |
| 45 | + # If Chart.yaml does not exist, treat it as a new version |
| 46 | + echo "version_changed=true" >> $GITHUB_ENV |
| 47 | + echo "Current version: None" |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Copy Helm Chart to my repo |
| 51 | + if: env.version_changed == 'true' |
| 52 | + run: | |
| 53 | + mkdir -p ./charts/local-path-provisioner |
| 54 | + # Copy the chart from upstream repo to the charts folder in the current repo |
| 55 | + cp -r upstream/deploy/chart/local-path-provisioner/* ./charts/local-path-provisioner/ |
| 56 | +
|
| 57 | + - name: Create Pull Request |
| 58 | + if: env.version_changed == 'true' |
| 59 | + uses: peter-evans/create-pull-request@v7 |
| 60 | + with: |
| 61 | + title: "Sync local-path-provisioner Helm chart to version ${{ env.UPSTREAM_VERSION }}" |
| 62 | + body: "This PR syncs the latest version of the local-path-provisioner chart from the upstream repository to version ${{ env.UPSTREAM_VERSION }}." |
| 63 | + branch: local-path-provisioner |
| 64 | + delete-branch: true |
| 65 | + commit-message: "Sync local-path-provisioner Helm chart to version ${{ env.UPSTREAM_VERSION }}" |
| 66 | + labels: | |
| 67 | + automated pr |
| 68 | + add-paths: | |
| 69 | + charts/local-path-provisioner/** |
0 commit comments