diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 7f53868..6e5fc7d 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -1,5 +1,8 @@ -name: Build Image +# This is a basic workflow to help you get started with Actions +name: Fetch Sponge Versions + +# Controls when the action will run. on: push: branches: @@ -9,11 +12,16 @@ on: - recommended-versions.json - Dockerfile - build-images.sh + - fetch-versions.sh + - .github/workflows/* + schedule: + - cron: '0 0 * * *' workflow_dispatch: jobs: build: runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 - name: Login to GitHub Container Registry @@ -24,3 +32,4 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push run: ./build-images.sh + diff --git a/.github/workflows/fetch-versions.yml b/.github/workflows/fetch-versions.yml deleted file mode 100644 index d7ceaca..0000000 --- a/.github/workflows/fetch-versions.yml +++ /dev/null @@ -1,25 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Fetch Sponge Versions - -# Controls when the action will run. -on: - schedule: - # * is a special character in YAML so you have to quote this string - - cron: '0 0 * * *' - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - fetch-versions: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - uses: actions/checkout@v3 - - name: Fetch Versions - run: ./fetch-versions.sh - diff --git a/build-images.sh b/build-images.sh index fa87aa5..dce4b0a 100755 --- a/build-images.sh +++ b/build-images.sh @@ -43,5 +43,10 @@ build_images() { done } -build_images latest -build_images recommended +if ./fetch-versions.sh +then + build_images latest + build_images recommended +else + echo "Nothing changed, nothing to build!" +fi diff --git a/fetch-versions.sh b/fetch-versions.sh index c19473f..abd310e 100755 --- a/fetch-versions.sh +++ b/fetch-versions.sh @@ -35,12 +35,29 @@ fetch_versions "api" true "${api_versions[@]}" | transform_to_versions > "$recom git config user.name 'CubeEngine Sponge Updater' git config user.email 'no-reply@cubeengine.org' -git add "$latest_versions_file" "$recommended_versions_file" +commit() { + local file="${1?no file}" + local name="${2?no name}" + git add "$file" + #git commit -m "$name updated" +} + +updated=false +if commit "$latest_versions_file" "Latest versions" +then + updated=true +fi +if commit "$recommended_versions_file" "Recommended versions" +then + updated=true +fi -if git commit -m 'My hands are typing words....' +if [ "$updated" = "true" ] then git push + exit 0 else echo "No new versions!" + exit 1 fi diff --git a/latest-versions.json b/latest-versions.json deleted file mode 100644 index 5977688..0000000 --- a/latest-versions.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "10": "1.19.4-10.0.0-RC1385", - "11": "1.20.2-11.0.0-RC1384", - "8": "1.16.5-8.2.1-RC1369", - "9": "1.18.2-9.0.0-RC1306" -} diff --git a/recommended-versions.json b/recommended-versions.json deleted file mode 100644 index ce251e4..0000000 --- a/recommended-versions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "8": "1.16.5-8.2.0" -}