From fca268c7517634e2a4fc1ed90f1168f68b1eac57 Mon Sep 17 00:00:00 2001 From: fherreazcue Date: Fri, 27 Oct 2023 08:24:10 +0100 Subject: [PATCH] Adds action to build and push --- .github/workflows/build-push.yml | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/build-push.yml diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 0000000..4f97517 --- /dev/null +++ b/.github/workflows/build-push.yml @@ -0,0 +1,76 @@ +name: build-push +run-name: 'build-push: versioned? ${{ github.event.inputs.versioned }} - latest? ${{ github.event.inputs.latest }}' + +on: + workflow_dispatch: + inputs: + versioned: + description: 'Push with versioned tag?' + required: true + type: boolean + default: true + latest: + description: 'Push with "latest" tag?' + required: true + type: boolean + default: true + +jobs: + build-test-push: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build + uses: docker/build-push-action@v4 + with: + context: . + load: true + tags: sandpaper:testing + + # - name: Test + # run: | + # expected="" + # actual="" + # if [ "$expected" = "$actual" ]; then + # echo "Passed - $actual" + # else + # echo "ERROR - Expected: $expected" + # echo " Actual: $actual" + # status=1 + # fi + + # exit $status + + - name: Create tag from sandpaper, varnish and pandoc versions + id: tag + run: | + sandpaper=$(grep "ARG sandpaper_version=" Dockerfile | cut -f2 -d"=") + varnish=$(grep "ARG varnish_version=" Dockerfile | cut -f2 -d"=") + pandoc=$(grep "ARG pandoc_version=" Dockerfile | cut -f2 -d"=") + echo "versions=s${sandpaper}-v${varnish}-p${pandoc}" >> $GITHUB_OUTPUT + echo $versions + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push versioned + if: github.event.inputs.versioned == 'true' + run: | + docker image tag sandpaper:testing ghcr.io/uomresearchit/sandpaper:${{ steps.tag.outputs.versions }} + docker push ghcr.io/uomresearchit/sandpaper:${{ steps.tag.outputs.versions }} + + - name: Push latest + if: github.event.inputs.latest == 'true' + run: | + docker image tag sandpaper:testing ghcr.io/uomresearchit/sandpaper:latest + docker push ghcr.io/uomresearchit/sandpaper::latest