From b7d2e339237321923bc22e3560a802280414796e Mon Sep 17 00:00:00 2001 From: Brandon Sturgeon Date: Wed, 24 Jul 2024 16:14:34 -0700 Subject: [PATCH] Auto updating --- .github/actions/build_and_push/action.yml | 83 +++++++++++++++++++++++ .github/workflows/build_and_push.yml | 80 ---------------------- .github/workflows/update.yml | 29 ++++++++ 3 files changed, 112 insertions(+), 80 deletions(-) create mode 100644 .github/actions/build_and_push/action.yml delete mode 100644 .github/workflows/build_and_push.yml create mode 100644 .github/workflows/update.yml diff --git a/.github/actions/build_and_push/action.yml b/.github/actions/build_and_push/action.yml new file mode 100644 index 0000000..c5c7804 --- /dev/null +++ b/.github/actions/build_and_push/action.yml @@ -0,0 +1,83 @@ +name: Build and Push +description: Builds and pushes the latest steamcmd image to GitHub Container Registry + +inputs: + tag_name: + description: "Tag name for the Docker image (or version tag)" + required: true + release: + type: boolean + description: "Is this a full release?" + required: true + github_token: + description: "GitHub token for pushing to GitHub Container Registry" + required: true + +runs: + using: "composite" + steps: + - name: Build + shell: bash + run: | + cd $GITHUB_WORKSPACE/bullseye + docker build \ + --target=bullseye \ + --tag ghcr.io/cfc-servers/steamcmd:${{ inputs.tag_name }} \ + --tag ghcr.io/cfc-servers/steamcmd:steam \ + . + + - name: Get docker-slim + shell: bash + run: | + SLIM_VERSION=1.40.11 + + curl --location --output ds.tar.gz https://github.com/slimtoolkit/slim/releases/download/$SLIM_VERSION/dist_linux.tar.gz + tar -xvzf ds.tar.gz + mv dist_linux/* $GITHUB_WORKSPACE + rm -rfv ds.tar.gz dist_linux/ + + - name: Make slim image + shell: bash + run: | + version=${{ inputs.tag_name }} + + $GITHUB_WORKSPACE/docker-slim build \ + --target ghcr.io/cfc-servers/steamcmd:$version \ + --http-probe-off \ + --show-clogs --show-blogs \ + --tag ghcr.io/cfc-servers/steamcmd-slim:$version \ + --tag ghcr.io/cfc-servers/steamcmd-slim:steam \ + --exec '/home/steam/steamcmd/steamcmd.sh +login anonymous +app_info_update +app_info_print 4020 +logoff +quit' + + - name: Add latest tag + shell: bash + run: | + BASE=ghcr.io/cfc-servers/steamcmd + version=${{ inputs.tag_name }} + + # Tag image with "0.27" if we push tag "0.27.5" + # but not if we push tag "0.27-pre5" + minorVersion=${version%.*} + if [[ $minorVersion != "0" ]]; then + echo "::warning:: Tagging with parent minor version: $minorVersion" + docker tag $BASE:$version $BASE:$minorVersion + docker tag $BASE-slim:$version $BASE-slim:$minorVersion + fi + + if [ "${{ inputs.release }}" = "true" ]; then + echo "::warning:: Tagging this release as the latest!" + docker tag $BASE:$version $BASE:latest + docker tag $BASE-slim:$version $BASE-slim:latest + fi + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ inputs.github_token }} + + - name: Tag and push slim images + run: | + docker push ghcr.io/cfc-servers/steamcmd --all-tags + docker push ghcr.io/cfc-servers/steamcmd-slim --all-tags diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml deleted file mode 100644 index 5ab40e8..0000000 --- a/.github/workflows/build_and_push.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Build and Push - -on: - workflow_dispatch: - inputs: - tag_name: - description: "Tag name for the Docker image (or version tag)" - required: true - release: - type: boolean - description: "Is this a full release?" - required: true - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Build - run: | - cd $GITHUB_WORKSPACE/bullseye - docker build \ - --target=bullseye \ - --tag ghcr.io/cfc-servers/steamcmd:${{ inputs.tag_name }} \ - --tag ghcr.io/cfc-servers/steamcmd:steam \ - . - - - name: Get docker-slim - run: | - SLIM_VERSION=1.40.11 - - curl --location --output ds.tar.gz https://github.com/slimtoolkit/slim/releases/download/$SLIM_VERSION/dist_linux.tar.gz - tar -xvzf ds.tar.gz - mv dist_linux/* $GITHUB_WORKSPACE - rm -rfv ds.tar.gz dist_linux/ - - - name: Make slim image - run: | - version=${{ inputs.tag_name }} - - $GITHUB_WORKSPACE/docker-slim build \ - --target ghcr.io/cfc-servers/steamcmd:$version \ - --http-probe-off \ - --show-clogs --show-blogs \ - --tag ghcr.io/cfc-servers/steamcmd-slim:$version \ - --tag ghcr.io/cfc-servers/steamcmd-slim:steam \ - --exec '/home/steam/steamcmd/steamcmd.sh +login anonymous +app_info_print 4020 +quit' - - - name: Add latest tag - run: | - BASE=ghcr.io/cfc-servers/steamcmd - version=${{ inputs.tag_name }} - - # Tag image with "0.27" if we push tag "0.27.5" - # but not if we push tag "0.27-pre5" - minorVersion=${version%.*} - if [[ $minorVersion != "0" ]]; then - echo "::warning:: Tagging with parent minor version: $minorVersion" - docker tag $BASE:$version $BASE:$minorVersion - docker tag $BASE-slim:$version $BASE-slim:$minorVersion - fi - - if [ "${{ inputs.release }}" = "true" ]; then - echo "::warning:: Tagging this release as the latest!" - docker tag $BASE:$version $BASE:latest - docker tag $BASE-slim:$version $BASE-slim:latest - fi - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Tag and push slim images - run: | - docker push ghcr.io/cfc-servers/steamcmd --all-tags - docker push ghcr.io/cfc-servers/steamcmd-slim --all-tags diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..12e3481 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,29 @@ +on: + workflow_dispatch: + schedule: + - cron: '18 4 */5 * *' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get Latest Tag + id: latest_tag + run: | + latest_tag=$(git describe --tags --abbrev=0 --match='[0-9]*.[0-9]*.[0-9]*' --match='[0-9]*.[0-9]*' --exclude='*[^0-9.]*') + + echo "Latest tag: $latest_tag" + echo "tag_name=$latest_tag" >> $GITHUB_OUTPUT + + - name: Push new build + uses: ./.github/actions/build_and_push + with: + tag: ${{ steps.latest_tag.outputs.tag_name }} + release: true + github_token: ${{ secrets.GITHUB_TOKEN }}