Add OWNERS (#13) #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Extensions Image Syncer | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
pull_request_push: | |
runs-on: ubuntu-latest | |
if: github.repository == 'kubesphere-extensions/ks-extensions' | |
steps: | |
- name: Get Architecture | |
id: get-architectures | |
run: | | |
ARCH=$(uname -m) | |
if [ "$ARCH" == "x86_64" ]; then | |
ARCH="amd64" | |
elif [ "$ARCH" == "aarch64" ]; then | |
ARCH="arm64" | |
fi | |
echo "arch=$ARCH" >> $GITHUB_OUTPUT | |
- name: Install KSBuilder | |
run: | | |
LATEST_RELEASE=$(curl -sH "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/kubesphere/ksbuilder/releases/latest" | jq -r '.tag_name') | |
curl -L -O https://github.com/kubesphere/ksbuilder/releases/download/$LATEST_RELEASE/ksbuilder_${LATEST_RELEASE#v}_linux_${{ steps.get-architectures.outputs.arch }}.tar.gz | |
sudo tar -zxf ksbuilder_${LATEST_RELEASE#v}_linux_${{ steps.get-architectures.outputs.arch }}.tar.gz -C /usr/local/bin/ ksbuilder | |
rm -rf ksbuilder_${LATEST_RELEASE#v}_linux_${{ steps.get-architectures.outputs.arch }}.tar.gz | |
- name: Install ORAS | |
run: | | |
VERSION="1.2.0" | |
curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_${{ steps.get-architectures.outputs.arch }}.tar.gz" | |
mkdir -p oras-install/ | |
tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/ | |
sudo mv oras-install/oras /usr/local/bin/ | |
rm -rf oras_${VERSION}_*.tar.gz oras-install/ | |
- name: Install yq | |
run: | | |
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${{ steps.get-architectures.outputs.arch }} -O /usr/bin/yq | |
sudo chmod +x /usr/bin/yq | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Login to HUAWEICLOUD | |
uses: docker/login-action@v3 | |
with: | |
registry: swr.cn-southwest-2.myhuaweicloud.com | |
username: ${{ secrets.HUAWEICLOUD_USERNAME }} | |
password: ${{ secrets.HUAWEICLOUD_PASSWORD }} | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v44 | |
- name: Extension Check | |
env: | |
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
run: | | |
changed_files=(${ALL_CHANGED_FILES}) | |
for path in ${changed_files[@]}; do | |
chart=$(dirname "$path") | |
if [[ $chart != '.' ]] && [ -f "$chart/extension.yaml" ] && [ -f "$chart/values.yaml" ]; then | |
ksbuilder package $chart | |
rm $chart-*.tgz | |
for image in $(yq eval '.images[]' $chart/extension.yaml); do | |
dstImage='' | |
if [[ ${image%%/*} =~ '.' ]]; then | |
dstImage=swr.cn-southwest-2.myhuaweicloud.com/ks/${image#*/} | |
elif [[ $image != */* ]]; then | |
dstImage="swr.cn-southwest-2.myhuaweicloud.com/ks/library/"$image | |
image="docker.io/library/"$image | |
else | |
dstImage="swr.cn-southwest-2.myhuaweicloud.com/ks/"$image | |
image="docker.io/"$image | |
fi | |
oras cp $image $dstImage | |
done | |
fi | |
done |