From 78d3102cfb40f95345e361caa28cd2b47a144b07 Mon Sep 17 00:00:00 2001 From: Valentin Riess Date: Fri, 13 Oct 2023 18:52:01 +0200 Subject: [PATCH 1/3] Add dockerhub workflow --- .github/workflows/main.yml | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ba70d4a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,54 @@ +name: Build and push Docker images +on: + push: + branches: + - main + +jobs: + build-and-push-docker-image: + name: Build Docker image and push to repositories + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build image and push to Docker Hub and GitHub Container Registry + uses: docker/build-push-action@v3 + id: docker_build + if: ${{ github.ref_name != 'main' }} + with: + # relative path to the place where source code with Dockerfile is located + context: . + # Note: tags has to be all lower-case + tags: | + valentinriess/hype:${{ github.ref_name }} + # build on feature branches, push only on develop branch + push: ${{ github.ref == 'refs/heads/develop' }} + + - name: Image digest + if: ${{ steps.docker_build.outcome == 'success' }} + run: echo ${{ steps.docker_build.outputs.digest }} + + - name: Build image and push to Docker Hub and GitHub Container Registry + uses: docker/build-push-action@v2 + id: docker_build_main + if: ${{ github.ref_name == 'main' }} + with: + # relative path to the place where source code with Dockerfile is located + context: . + # Note: tags has to be all lower-case + tags: | + valentinriess/hype:latest + # build on feature branches, push only on develop branch + push: ${{ github.ref == 'refs/heads/main' }} + + - name: Image digest + if: ${{ steps.docker_build_main.outcome == 'success' }} + run: echo ${{ steps.docker_build_main.outputs.digest }} \ No newline at end of file From 6d691511a65fa5cd6d38129fe3e994fc07a42482 Mon Sep 17 00:00:00 2001 From: Valentin Riess Date: Fri, 13 Oct 2023 18:55:16 +0200 Subject: [PATCH 2/3] Fix workflow to also run on develop --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba70d4a..f996751 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - develop jobs: build-and-push-docker-image: From 210973a12fa35db3630fecb843bea67003edb3c1 Mon Sep 17 00:00:00 2001 From: Valentin Riess Date: Fri, 13 Oct 2023 19:02:21 +0200 Subject: [PATCH 3/3] Update action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f996751..7ed0b81 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }}