2023-09-15 17:07:32 +00:00
|
|
|
# Generate-Regsync-Config action will run for every PR into release-v2.7 branch only after an approval is given
|
|
|
|
# It will run make target to generate regsync file and add a commit to the PR updating the regsync file.
|
|
|
|
# It will then install and run regsync client and do the prime image mirroring.
|
2023-05-03 21:00:57 +00:00
|
|
|
|
|
|
|
name: Generate-Regsync-Config
|
|
|
|
|
|
|
|
on:
|
2023-10-10 12:12:27 +00:00
|
|
|
pull_request_target:
|
|
|
|
types:
|
|
|
|
- labeled
|
2023-05-03 21:00:57 +00:00
|
|
|
|
|
|
|
jobs:
|
2023-10-10 12:12:27 +00:00
|
|
|
onLabelAndApproval:
|
|
|
|
if: github.event.label.name == 'regsync-ready' && startsWith(github.event.pull_request.base.ref, 'release-v')
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
is_approved: ${{ steps.check-approval.outputs.approved }}
|
|
|
|
steps:
|
|
|
|
- name: Check if PR is approved
|
|
|
|
id: check-approval
|
|
|
|
run: |
|
|
|
|
IS_APPROVED=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews --jq '[.[] | select(.state == "APPROVED")] | length')
|
|
|
|
if [[ "$IS_APPROVED" -gt 0 ]]; then
|
|
|
|
echo "::set-output name=approved::true"
|
|
|
|
else
|
|
|
|
echo "::set-output name=approved::false"
|
|
|
|
fi
|
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2023-05-03 21:00:57 +00:00
|
|
|
build:
|
2023-10-10 12:12:27 +00:00
|
|
|
needs: onLabelAndApproval
|
|
|
|
if: needs.onLabelAndApproval.outputs.is_approved == 'true'
|
2023-05-03 21:00:57 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-10-10 12:12:27 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.PUSH_TOKEN }}
|
|
|
|
|
|
|
|
- name: Set-up Ruby 3.2
|
|
|
|
uses: ruby/setup-ruby@v1
|
|
|
|
with:
|
|
|
|
ruby-version: '3.2' # Not needed with a .ruby-version file
|
2023-05-03 21:00:57 +00:00
|
|
|
|
|
|
|
# Need to remove export version once rancher/charts gets the latest version
|
|
|
|
# of charts-build-script binary.
|
2023-10-10 12:12:27 +00:00
|
|
|
# Test removal of regsync.yaml, commit and push before regenerating it
|
|
|
|
- name: Generate RegSync
|
2023-05-03 21:00:57 +00:00
|
|
|
run: |
|
2023-10-10 12:12:27 +00:00
|
|
|
echo ${{ secrets.PUSH_TOKEN }} | gh auth login --with-token
|
|
|
|
gh pr checkout ${{ github.event.pull_request.number }}
|
|
|
|
git config --global user.email "${{ secrets.USER_GITHUB }}"
|
|
|
|
git config --global user.name "rancherbot"
|
2023-05-03 21:00:57 +00:00
|
|
|
export CHARTS_BUILD_SCRIPT_VERSION=v0.4.2
|
|
|
|
make pull-scripts
|
|
|
|
make regsync
|
2023-10-10 12:12:27 +00:00
|
|
|
|
|
|
|
- name: Commit files
|
|
|
|
run: |
|
|
|
|
git add regsync.yaml
|
|
|
|
git commit -m "Updating resync.yaml"
|
|
|
|
git branch
|
|
|
|
git push
|
|
|
|
|
2023-06-20 17:30:21 +00:00
|
|
|
- name: Install Regsync
|
|
|
|
run: |
|
2023-08-31 16:22:44 +00:00
|
|
|
curl --silent --fail --location --output regsync https://github.com/regclient/regclient/releases/download/v0.5.1/regsync-linux-amd64
|
2023-06-20 20:04:45 +00:00
|
|
|
chmod +x regsync
|
2023-06-22 15:06:36 +00:00
|
|
|
|
2023-06-22 17:35:55 +00:00
|
|
|
- name: Sync Images to Registry
|
2023-06-22 15:38:23 +00:00
|
|
|
run: |
|
2023-06-22 15:40:44 +00:00
|
|
|
head regsync.yaml
|
2023-10-10 12:12:27 +00:00
|
|
|
ruby ./regsync-split.rb
|
|
|
|
time find regsync -type f -name split-regsync.yaml -print -exec time regsync once --config '{}' ';'
|
2023-06-22 15:38:23 +00:00
|
|
|
env:
|
|
|
|
REGISTRY_ENDPOINT: ${{ secrets.REGISTRY_ENDPOINT }}
|
|
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
2023-10-10 12:12:27 +00:00
|
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|