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
|
|
|
|
2023-10-10 12:12:27 +00:00
|
|
|
- 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
|
|
|
make pull-scripts
|
|
|
|
make regsync
|
2023-10-10 12:12:27 +00:00
|
|
|
|
2023-10-23 19:36:13 +00:00
|
|
|
- name: Check for modifications in regsync.yaml
|
|
|
|
id: check_changes
|
|
|
|
run: |
|
|
|
|
git diff --quiet regsync.yaml || echo "::set-output name=changed::true"
|
|
|
|
|
2023-10-10 12:12:27 +00:00
|
|
|
- name: Commit files
|
2023-10-23 19:36:13 +00:00
|
|
|
if: steps.check_changes.outputs.changed == 'true'
|
2023-10-10 12:12:27 +00:00
|
|
|
run: |
|
|
|
|
git add regsync.yaml
|
|
|
|
git commit -m "Updating resync.yaml"
|
|
|
|
git push
|
|
|
|
|
2023-10-23 19:36:13 +00:00
|
|
|
- name: No changes in regsync.yaml
|
|
|
|
if: steps.check_changes.outputs.changed != 'true'
|
|
|
|
run: |
|
|
|
|
echo "regsync.yaml is the same"
|
|
|
|
|
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-10-23 19:28:35 +00:00
|
|
|
export PATH=$PATH:$(pwd)
|
2023-06-22 15:40:44 +00:00
|
|
|
head regsync.yaml
|
2023-10-24 00:47:13 +00:00
|
|
|
ruby ./scripts/regsync-split.rb
|
2023-10-23 21:59:07 +00:00
|
|
|
tree ./split-regsync
|
2023-10-23 19:28:35 +00:00
|
|
|
time find split-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 }}
|