Skip to content

Commit

Permalink
upgrading registry job (old regsync) to support new prime registry ch…
Browse files Browse the repository at this point in the history
…eck strategy
  • Loading branch information
nicholasSUSE committed Feb 13, 2025
1 parent 22d0a3a commit 622ce26
Showing 1 changed file with 38 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generate-Regsync-Config action will run for every PR into release-v2.9 branch only after an approval is given
# 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.

Expand Down Expand Up @@ -37,56 +37,76 @@ jobs:
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
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: Generate RegSync
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- 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"
make pull-scripts
make regsync
- name: Check for modifications in regsync.yaml
id: check_changes
- name: Generate RegSync
continue-on-error: false
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git diff --quiet regsync.yaml || echo "::set-output name=changed::true"
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: Commit files
- name: Push
continue-on-error: false
if: steps.check_changes.outputs.changed == 'true'
run: |
git add regsync.yaml
git commit -m "Updating resync.yaml"
git push
- name: No changes in regsync.yaml
if: steps.check_changes.outputs.changed != 'true'
run: |
echo "regsync.yaml is the same"
- 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
Expand Down

0 comments on commit 622ce26

Please sign in to comment.