From 91532b5d538d74a2e607e095268aeb87c6ce20c1 Mon Sep 17 00:00:00 2001 From: Manuel Lera-Ramirez Date: Mon, 22 Jul 2024 17:10:44 +0100 Subject: [PATCH] add action to push to dockerhub --- .github/workflows/deploy_dockerhub.yaml | 42 +++++++++++++++++++++++++ docs/deployment.md | 11 ------- 2 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/deploy_dockerhub.yaml delete mode 100644 docs/deployment.md diff --git a/.github/workflows/deploy_dockerhub.yaml b/.github/workflows/deploy_dockerhub.yaml new file mode 100644 index 0000000..a0e9ccd --- /dev/null +++ b/.github/workflows/deploy_dockerhub.yaml @@ -0,0 +1,42 @@ +name: Deploy to Docker Hub +on: + workflow_dispatch: + +# Avoid running multiple jobs for the same branch +# in case of updates. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + # Update docker image when committing to prod branch if tests pass + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/prod' + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: manulera/shareyourcloning + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: manulera/shareyourcloning:latest + labels: ${{ steps.meta.outputs.labels }} diff --git a/docs/deployment.md b/docs/deployment.md deleted file mode 100644 index 2ddac5f..0000000 --- a/docs/deployment.md +++ /dev/null @@ -1,11 +0,0 @@ -# Deployment - -Probably both of these should be switched to on release. - -## Frontend - -Commit to prod branch, that's automatically picked by netlify. A test should be added that checks that site can be built correctly and to the right directory before atempting to deploy. - -## Backend - -Commit to prod branch, if tests are passed, it will commit to dockerhub. Maybe the tests should also be ran on the docker container itself before deploying, otherwise some error may occur (e.g. change in python version, although that may make the container build to fail if the dependencies are not met). \ No newline at end of file