diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml new file mode 100644 index 0000000..957d659 --- /dev/null +++ b/.github/workflows/build_and_deploy.yml @@ -0,0 +1,29 @@ +name: Build and Deploy + +on: + push: + branches: + - main + tags: + - '\d+.\d+.\d+' + +permissions: + id-token: write + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Login to Dockerhub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build, Tag, and Push Docker Image + run: | + ci/docker-build-image -p + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ee3505..15f51c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,3 +55,10 @@ See [Semantic Versioning](https://semver.org/) for help selecting the next versi - If the jobs completed successfully, a new tag matching the "#.#.#" pattern should have been added to main. You can check the [tags page](https://github.com/seqwell/longplexpy/tags) - If the jobs completed successfully, there should also be a new release on the [releases page](https://github.com/seqwell/longplexpy/releases). + + +## Confirm the Docker Image was Built and Deployed +- Navigate to [Build and Deploy Action](https://github.com/seqwell/longplexpy/actions/workflows/build_and_deploy.yml) +- You should see two workflow runs with titles similar to the PR title, "chore(#.#.#): update pyproject version". +One should have a triggering event as the new tag "#.#.#" and one should have a triggering event as `main`. +- A green checkmark on these actions indicates the docker image was built, tagged, and pushed to the [seqwell/longplexpy](https://registry.hub.docker.com/r/seqwell/longplexpy) repo on Dockerhub. diff --git a/ci/docker-build-image b/ci/docker-build-image index 7bf907f..22df6ea 100755 --- a/ci/docker-build-image +++ b/ci/docker-build-image @@ -23,14 +23,16 @@ Ensure your Docker daemon is running with these minimum resource allocations: Options: -h Display this information. -n Do not use the Docker cache during build. (Optional) + -p Push image to Dockerhub, requires docker login (Optional) EOF } -DOCKER_NO_CACHE=""; -while getopts "hn" OPTION; do +DOCKER_NO_CACHE=""; PUSH_IMAGE="" +while getopts "hnp" OPTION; do case "$OPTION" in h) usage; exit 1;; n) DOCKER_NO_CACHE="--no-cache";; + p) PUSH_IMAGE="True";; [?]) usage; (>&2 echo "Exception: Unknown options ${*}."); exit 1;; esac done @@ -47,3 +49,8 @@ LONGPLEXPY_VERSION="$(git describe --exact-match 2>/dev/null || git describe --a --file docker/Dockerfile \ . ) + +if [ -n "$PUSH_IMAGE" ]; +then + docker push seqwell/longplexpy:"${LONGPLEXPY_VERSION}" +fi