Skip to content

Testing fixes to regsync action #578

Testing fixes to regsync action

Testing fixes to regsync action #578

Workflow file for this run

# 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.
name: Generate-Regsync-Config
on:
pull_request:
types:
- labeled
jobs:
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 }}
build:
needs: onLabelAndApproval
if: needs.onLabelAndApproval.outputs.is_approved == 'true'
runs-on: ubuntu-latest
steps:
- 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
# Need to remove export version once rancher/charts gets the latest version
# of charts-build-script binary.
# Test removal of regsync.yaml, commit and push before regenerating it
# - name: Generate RegSync
# run: |
# 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"
# export CHARTS_BUILD_SCRIPT_VERSION=v0.4.2
# make pull-scripts
# make regsync
# - name: Commit files
# run: |
# git add regsync.yaml
# git commit -m "Updating resync.yaml"
# git branch
# git push
- name: Install Regsync
run: |
curl --silent --fail --location --output regsync https://github.com/regclient/regclient/releases/download/v0.5.1/regsync-linux-amd64
chmod +x regsync
- name: Sync Images to Registry
run: |
export PATH=$PATH:$(pwd)
head regsync.yaml
ruby ./regsync-split.rb
ls split-regsync/docker.io/rancher
time find split-regsync -type f -name split-regsync.yaml -print -exec time regsync once --config '{}' ';'
env:
REGISTRY_ENDPOINT: ${{ secrets.REGISTRY_ENDPOINT }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}