Skip to content

[release-v2.10] Regsync remove cosign check, implement skopeo tag listing #1

[release-v2.10] Regsync remove cosign check, implement skopeo tag listing

[release-v2.10] Regsync remove cosign check, implement skopeo tag listing #1

Workflow file for this run

# Generate-Regsync-Config action will run for every PR into release-v2.* 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
permissions:
contents: write
id-token: write
steps:
- name: Read App Secrets
continue-on-error: false
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ;
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY ;
- name: Create App Token
continue-on-error: false
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ env.APP_ID }}
private-key: ${{ env.PRIVATE_KEY }}
- name: Checkout
continue-on-error: false
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Set-up Ruby 3.2
continue-on-error: false
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2' # Not needed with a .ruby-version file
- name: Install Skopeo
continue-on-error: false
run: |
sudo apt-get update
sudo apt-get install -y skopeo
- name: Git Setup
continue-on-error: false
run: |
gh pr checkout ${{ github.event.pull_request.number }}
git config --global user.email "${{ secrets.USER_GITHUB }}"
git config --global user.name "rancherbot"
- name: Generate RegSync
continue-on-error: false
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
make pull-scripts
last_line=$(make regsync | tail -n 1 | tr -d '\r') # Capture and remove any carriage returns
last_line=$(echo "$last_line" | tr -d '\n') # Remove any newlines
echo "::set-output name=changes::$last_line" # Set the output variable
echo "Last line: $last_line" # For debugging
if [[ "$last_line" == "YES" ]]; then
echo "Changes detected. Continuing workflow."
elif [[ "$last_line" == "NO" ]]; then
echo "No changes detected. Skipping workflow."
exit 0 # Graceful exit to prevent error
else
echo "Unexpected output from make regsync: $last_line"
exit 1 # Error exit to stop the workflow
fi
- name: Push
continue-on-error: false
if: steps.check_changes.outputs.changed == 'true'
run: |
git push
- name: Install Regsync
continue-on-error: false
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 ./scripts/regsync-split.rb
tree ./split-regsync
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 }}