From d8399a4d8876abd42e3ce191a05e516b4b157c45 Mon Sep 17 00:00:00 2001 From: GilbN <24592972+GilbN@users.noreply.github.com> Date: Sun, 20 Mar 2022 18:39:21 +0100 Subject: [PATCH] Create docker-build.yml --- .github/workflows/docker-build.yml | 66 ++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..7c518fc9 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,66 @@ +name: docker build +on: + release: + types: + - published + branches: + - live + - live_develop +jobs: + push_to_ghcr_io: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} + - name: Set current date as env variable + id: date_time + run: echo ::set-output name=NOW::$(date +'%Y-%m-%dT%H:%M:%S') + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GH_PAT }} + - name: build&push live + if: ${{ github.ref == 'refs/heads/live' }} + run: | + docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} + docker push ghcr.io/gilbn/theme.park + - name: build&push dev + if: ${{ github.ref == 'refs/heads/live_develop' }} + run: | + docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park:develop --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} + docker push --all-tags ghcr.io/gilbn/theme.park + push_to_dockerhub: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} + - name: Set current date as env variable + id: date_time + run: echo ::set-output name=NOW::$(date +'%Y-%m-%dT%H:%M:%S') + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DH_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: build&push dh live + if: ${{ github.ref == 'refs/heads/live' }} + run: | + docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag ghcr.io/gilbn/theme.park --tag ghcr.io/gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} + docker push ghcr.io/gilbn/theme.park + - name: build&push dh dev + if: ${{ github.ref == 'refs/heads/live_develop' }} + run: | + docker build docker/ --build-arg TP_RELEASE=${{ steps.get_version.outputs.VERSION }} --build-arg BUILD_DATE=${{ steps.date_time.outputs.NOW }} --tag gilbn/theme.park:develop --tag gilbn/theme.park:${{ steps.get_version.outputs.VERSION }} + docker push --all-tags gilbn/theme.park