Build Image #357
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
# This is a basic workflow to help you get started with Actions | |
name: Build Image | |
# 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" | |
build: | |
# 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/cache@v3 | |
with: | |
path: last_sponge_build | |
key: api-8-build-2 | |
- name: Fetch Last Sponge Build | |
id: sponge-check | |
run: | | |
curl "https://api.github.com/repos/SpongePowered/Sponge/actions/workflows/deploy.yaml/runs?per_page=1&status=completed&branch=api-8" | jq '.workflow_runs [0] .run_number' > latest_sponge_build | |
if cmp -s last_sponge_build latest_sponge_build; then | |
echo ::set-output name=modified::false | |
echo No New Sponge Build $(cat last_sponge_build)! Skipping | |
else | |
echo ::set-output name=modified::true | |
echo New Sponge Build: $(cat -s last_sponge_build) to $(cat latest_sponge_build) | |
mv -f latest_sponge_build last_sponge_build | |
fi | |
- name: Set up Docker Buildx | |
if: steps.sponge-check.outputs.modified == 'true' | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Registry | |
if: steps.sponge-check.outputs.modified == 'true' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
if: steps.sponge-check.outputs.modified == 'true' | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: ghcr.io/cubeengine/sponge:1.16.5-8.2.0 |