From b565a451a9b4ef405906f2f88ec33afa0bd04ffb Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Mon, 19 Aug 2024 16:15:21 +0100 Subject: [PATCH] Create push_dockerhub.yml --- .github/workflows/push_dockerhub.yml | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/push_dockerhub.yml diff --git a/.github/workflows/push_dockerhub.yml b/.github/workflows/push_dockerhub.yml new file mode 100644 index 0000000..d8f826b --- /dev/null +++ b/.github/workflows/push_dockerhub.yml @@ -0,0 +1,45 @@ +name: Docker push +# This builds the docker image and pushes it to DockerHub +# Runs on artic-network/rampart repo releases +# and push event to 'dev' branch (PR merges) +on: + push: + branches: + - dev + release: + types: [published] + +jobs: + push_dockerhub: + name: Push new Docker image to Docker Hub + runs-on: ubuntu-latest + + if: ${{ github.repository == 'artic-network/rampart' }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASS: ${{ secrets.DOCKERHUB_PASS }} + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Check out pipeline code + uses: actions/checkout@v2 + + - name: Build new docker image + run: docker build --no-cache . -t articnetworkorg/rampart:latest + + - name: Push Docker image to DockerHub (dev) + if: ${{ github.event_name == 'push' }} + run: | + echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin + docker tag articnetworkorg/rampart:latest articnetworkorg/rampart:dev + docker push articnetworkorg/rampart:dev + - name: Push Docker image to DockerHub (release) + if: ${{ github.event_name == 'release' }} + run: | + echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin + docker push articnetworkorg/rampart:latest + docker tag articnetworkorg/rampart:latest articnetworkorg/rampart:${{ github.event.release.tag_name }} + docker push articnetworkorg/rampart:${{ github.event.release.tag_name }}