From fffd73d3fc5a91ba32fa0259ea9aba2c0da42814 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 22 Apr 2023 11:22:39 +0100 Subject: Add GitHub workflow for building and publishing the docker image --- .github/workflows/ci.yml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c051171 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI +on: [push, pull_request] +env: + dockerid: ${{ secrets.dockerid }} + dockerpass: ${{ secrets.dockerpass }} +jobs: + build: + name: Build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # List of tags to build and upload, remember to update this + tag: [0.4.4] + env: + dockertag: ${{ matrix.tag }} + dockerimg: openrct2/openrct2-cli + dockerlst: 0.4.4 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build docker image + run: | + ctxpath=${dockertag//-/\/}/cli + echo "Building $dockerimg:$dockertag from $ctxpath..." + docker build -t $dockerimg:$dockertag $ctxpath + - name: Tag latest docker image + run: | + if [ "$dockertag" == "$dockerlst" ]; then + echo "Tagging $dockerimg:$dockertag as $dockerimg:latest..." + docker tag $dockerimg:$dockertag $dockerimg:latest + else + echo "Latest tag not updated" + fi + - name: Login to docker + run: | + if [ "$dockerid" != "" ]; then + docker login -u "$dockerid" -p "$dockerpass" + echo "Docker login successful" + else + echo "No docker login performed" + fi + - name: Publish docker images + if: startsWith(github.ref, 'refs/tags/v') + run: | + if [ "$dockerid" != "" ]; then + echo "Pushing $dockerimg:$dockertag..." + docker push $dockerimg:$dockertag + if [ "$dockertag" == "$dockerlst" ]; then + echo "Pushing $dockerimg:latest..." + docker push $dockerimg:latest + fi + else + echo "No docker images published" + fi -- cgit v1.2.3