name: Docker Image CI on: push: branches: [ master ] schedule: - cron: "0 * * * *" jobs: status-build: runs-on: ubuntu-latest if: github.event.pull_request.merged == false steps: - uses: actions/checkout@v3 - name: Check new version continue-on-error: true id: status run: | LOCALAPPVER=($(cat sandstorm.version)) REMOTEAPPVER=($(curl -s -X GET 'https://api.steamcmd.net/v1/info/581330' | jq -r -e '.data."581330".depots."581333".manifests.public')) if [ -z "$REMOTEAPPVER" -a "$REMOTEAPPVER" = " " ]; then echo "Empty Response" exit 1 fi if [[ "$LOCALAPPVER" != "$REMOTEAPPVER" ]]; then echo "$REMOTEAPPVER" >sandstorm.version exit 0 else echo "Version not changed" exit 1 fi shell: bash - name: Login to DockerHub if: steps.status.outcome == 'success' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push id: build if: steps.status.outcome == 'success' uses: docker/build-push-action@v3 with: context: . push: true tags: andrewmhub/insurgency-sandstorm:latest - name: login to git if: steps.status.outcome == 'success' run: | git config --global user.name 'Andrew Marchukov' git config --global user.email "${EMAIL}" git remote set-url origin https://x-access-token:${{ secrets.GIT_TOKEN }}@github.com/AndrewMarchukov/insurgency-sandstorm-server-dockerize.git - name: check for changes if: steps.status.outcome == 'success' run: git status - name: stage changed files if: steps.status.outcome == 'success' run: git add sandstorm.version - name: commit changed files if: steps.status.outcome == 'success' run: git commit -m "Auto updating sandstorm.version" - name: fetch from master if: steps.status.outcome == 'success' run: git fetch origin master - name: push code to master if: steps.status.outcome == 'success' run: git push origin HEAD:master build: runs-on: ubuntu-latest if: github.event.pull_request.merged == true steps: - uses: actions/checkout@v3 - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push id: build uses: docker/build-push-action@v3 with: context: . push: true tags: andrewmhub/insurgency-sandstorm:latest