From 42722c9fbf6a584a917d0743c385831f6df2c06e Mon Sep 17 00:00:00 2001 From: "David H." <22520563+NewJerseyStyle@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:57:33 -0500 Subject: [PATCH 1/3] Create release-dockerhub-images.yml for #101 --- .../workflows/release-dockerhub-images.yml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/.github/workflows/release-dockerhub-images.yml diff --git a/.github/workflows/.github/workflows/release-dockerhub-images.yml b/.github/workflows/.github/workflows/release-dockerhub-images.yml new file mode 100644 index 000000000..cb7dd220e --- /dev/null +++ b/.github/workflows/.github/workflows/release-dockerhub-images.yml @@ -0,0 +1,45 @@ +# Changes to workflow name require changes to badge URL in README.md +name: Docker image builds + +on: + push: + branches: + - main + - dev + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + env: + # Use native docker command within docker-compose + COMPOSE_DOCKER_CLI_BUILD: 1 + # Use buildkit to speed up docker command + DOCKER_BUILDKIT: 1 + steps: + + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + ref: ${{ steps.extranct_branch.outputs.branch }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build full project via docker-compose + run: | + mv example.env .env + sed -i 's/compdem/${{ secrets.DOCKER_USERNAME }}/g' docker-compose.yml + docker compose build --parallel --build-arg GIT_HASH=${GITHUB_SHA:0:6} + - name: Push images to Docker Hub + run: docker compose push --ignore-push-failures From c3ff2bbafcb65b35056818e47a9f9c290ca69782 Mon Sep 17 00:00:00 2001 From: "David H." <22520563+NewJerseyStyle@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:46:51 -0500 Subject: [PATCH 2/3] Merge instructions from release-dockerhub-images.yml --- .github/workflows/release-docker-images.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-docker-images.yml b/.github/workflows/release-docker-images.yml index 673c8b61a..872993a0a 100644 --- a/.github/workflows/release-docker-images.yml +++ b/.github/workflows/release-docker-images.yml @@ -26,13 +26,19 @@ jobs: with: ref: ${{ steps.extract_branch.outputs.branch }} - - name: Login to Docker Hub + - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.CR_PAT }} + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build full project via docker-compose run: | mv example.env .env @@ -40,5 +46,14 @@ jobs: sed -i 's/compdem/civictechto/g' docker-compose.yml docker compose --profile postgres build --parallel --build-arg GIT_HASH=${GITHUB_SHA:0:6} - - name: Push images to Docker Hub + - name: Push images to GHCR run: docker compose --profile postgres push --ignore-push-failures + + - name: Push images to Docker Hub + run: | + for image in $(docker images --format='{{.Repository}}:{{.Tag}}'); do + IMAGE_NAME=$(echo "$image" | sed 's/ghcr.io/docker.io/g') + IMAGE_NAME=$(echo "$IMAGE_NAME" | sed 's/civictechto/${{ secrets.DOCKER_USERNAME }}/g') + docker tag $image $IMAGE_NAME + done + docker compose --profile postgres push --ignore-push-failures From ea3b821b9f132f9fc07b9d495e1512f65a8afdcd Mon Sep 17 00:00:00 2001 From: "David H." <22520563+NewJerseyStyle@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:47:17 -0500 Subject: [PATCH 3/3] Delete .github/workflows/.github/workflows/release-dockerhub-images.yml --- .../workflows/release-dockerhub-images.yml | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/workflows/.github/workflows/release-dockerhub-images.yml diff --git a/.github/workflows/.github/workflows/release-dockerhub-images.yml b/.github/workflows/.github/workflows/release-dockerhub-images.yml deleted file mode 100644 index cb7dd220e..000000000 --- a/.github/workflows/.github/workflows/release-dockerhub-images.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Changes to workflow name require changes to badge URL in README.md -name: Docker image builds - -on: - push: - branches: - - main - - dev - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - env: - # Use native docker command within docker-compose - COMPOSE_DOCKER_CLI_BUILD: 1 - # Use buildkit to speed up docker command - DOCKER_BUILDKIT: 1 - steps: - - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - - name: Checkout - uses: actions/checkout@v2.3.4 - with: - ref: ${{ steps.extranct_branch.outputs.branch }} - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} - - - name: Build full project via docker-compose - run: | - mv example.env .env - sed -i 's/compdem/${{ secrets.DOCKER_USERNAME }}/g' docker-compose.yml - docker compose build --parallel --build-arg GIT_HASH=${GITHUB_SHA:0:6} - - name: Push images to Docker Hub - run: docker compose push --ignore-push-failures