From 6def4a481b3ad0a7b83f29a45f7233b686eef91f Mon Sep 17 00:00:00 2001 From: znorgaard Date: Tue, 10 Dec 2024 09:10:41 -0800 Subject: [PATCH 1/7] feat: add build and deploy action --- .github/workflows/build_and_deploy.yml | 31 ++++++++++++++++++++++++++ ci/docker-build-image | 6 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_and_deploy.yml diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml new file mode 100644 index 0000000..34b56b1 --- /dev/null +++ b/.github/workflows/build_and_deploy.yml @@ -0,0 +1,31 @@ +name: Build and Deploy + +on: + push: + branches: + # TODO: Switch back to main + - zn_dockerhub + 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: + token: ${{ secrets.GITHUB_TOKEN }} + - 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: | + # TODO: Add -p (push) flag + ci/docker-build-image + diff --git a/ci/docker-build-image b/ci/docker-build-image index 7bf907f..679ec02 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 +while getopts "hnp" OPTION; do case "$OPTION" in h) usage; exit 1;; n) DOCKER_NO_CACHE="--no-cache";; + p) PUSH_IMAGES="--push";; [?]) usage; (>&2 echo "Exception: Unknown options ${*}."); exit 1;; esac done @@ -45,5 +47,5 @@ LONGPLEXPY_VERSION="$(git describe --exact-match 2>/dev/null || git describe --a ${DOCKER_NO_CACHE} \ --tag seqwell/longplexpy:"${LONGPLEXPY_VERSION}" \ --file docker/Dockerfile \ - . + "${PUSH_IMAGES}" . ) From 2462faa43c1c4c098b8f550947b7de96e1dde07c Mon Sep 17 00:00:00 2001 From: znorgaard Date: Tue, 10 Dec 2024 09:14:52 -0800 Subject: [PATCH 2/7] fix: fetch depth --- .github/workflows/build_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 34b56b1..8cc47f7 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: - token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 - name: Login to Dockerhub uses: docker/login-action@v3 with: From 9c159c4efe0e98c927f69db38597881735f30911 Mon Sep 17 00:00:00 2001 From: znorgaard Date: Tue, 10 Dec 2024 09:16:15 -0800 Subject: [PATCH 3/7] fix: define PUSH_IMAGES --- ci/docker-build-image | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/docker-build-image b/ci/docker-build-image index 679ec02..5f8bd02 100755 --- a/ci/docker-build-image +++ b/ci/docker-build-image @@ -27,7 +27,7 @@ Options: EOF } -DOCKER_NO_CACHE=""; +DOCKER_NO_CACHE=""; PUSH_IMAGES="" while getopts "hnp" OPTION; do case "$OPTION" in h) usage; exit 1;; From 3dcfdaa23a4a5278084461de6f4572dc39e7b222 Mon Sep 17 00:00:00 2001 From: znorgaard Date: Tue, 10 Dec 2024 09:26:54 -0800 Subject: [PATCH 4/7] fix: docker push --- ci/docker-build-image | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ci/docker-build-image b/ci/docker-build-image index 5f8bd02..22df6ea 100755 --- a/ci/docker-build-image +++ b/ci/docker-build-image @@ -27,12 +27,12 @@ Options: EOF } -DOCKER_NO_CACHE=""; PUSH_IMAGES="" +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_IMAGES="--push";; + p) PUSH_IMAGE="True";; [?]) usage; (>&2 echo "Exception: Unknown options ${*}."); exit 1;; esac done @@ -47,5 +47,10 @@ LONGPLEXPY_VERSION="$(git describe --exact-match 2>/dev/null || git describe --a ${DOCKER_NO_CACHE} \ --tag seqwell/longplexpy:"${LONGPLEXPY_VERSION}" \ --file docker/Dockerfile \ - "${PUSH_IMAGES}" . + . ) + +if [ -n "$PUSH_IMAGE" ]; +then + docker push seqwell/longplexpy:"${LONGPLEXPY_VERSION}" +fi From 9f8b271c3fb065cc53ac3d4862c627ade644e75f Mon Sep 17 00:00:00 2001 From: znorgaard Date: Tue, 10 Dec 2024 09:28:02 -0800 Subject: [PATCH 5/7] chore: use final resources --- .github/workflows/build_and_deploy.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 8cc47f7..957d659 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -3,8 +3,7 @@ name: Build and Deploy on: push: branches: - # TODO: Switch back to main - - zn_dockerhub + - main tags: - '\d+.\d+.\d+' @@ -26,6 +25,5 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build, Tag, and Push Docker Image run: | - # TODO: Add -p (push) flag - ci/docker-build-image + ci/docker-build-image -p From f35a34f619f251ab87c9247e64a8fdfec95c6997 Mon Sep 17 00:00:00 2001 From: znorgaard Date: Tue, 10 Dec 2024 09:35:15 -0800 Subject: [PATCH 6/7] docs: update contributing guide --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ee3505..6214377 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 Build 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. From 6d043ff2aae9830bf692427e72fde86c3425d68e Mon Sep 17 00:00:00 2001 From: znorgaard Date: Tue, 10 Dec 2024 09:35:57 -0800 Subject: [PATCH 7/7] fix: typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6214377..15f51c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,7 +57,7 @@ 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 Build and Deployed +## 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`.