From d8043196f7406ef4d209d861bd539505eebc5401 Mon Sep 17 00:00:00 2001 From: Martin Varga Date: Mon, 10 Mar 2025 08:39:39 +0100 Subject: [PATCH 1/2] Chore: Publish docker images to dockerhub --- .github/workflows/publish.yaml | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..f8821d00 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,40 @@ +name: Build and publish public images +on: + workflow_dispatch: + +env: + REGISTRY: docker.io + REPOSITORY: lutraconsulting/merginmaps + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKERHUB_LOGIN }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build, tag, and push CE images to Dockerhub + env: + BUILD_HASH: ${{ github.sha }} + run: | + IMAGE_TAG=${{ github.ref_name }} + if [[ $GITHUB_REF_TYPE != "tag" ]]; then + echo "Not a tag, exiting" + exit 1 + fi + echo "IMAGE_TAG=$IMAGE_TAG" >> "$GITHUB_ENV" + cd server + docker build -f Dockerfile . --build-arg BUILD_HASH=${BUILD_HASH} -t $REGISTRY/$REPOSITORY-backend:$IMAGE_TAG; + cd ../web-app + docker build -f Dockerfile . -t $REGISTRY/$REPOSITORY-frontend:$IMAGE_TAG + docker push $REGISTRY/$REPOSITORY-backend:$IMAGE_TAG + docker push $REGISTRY/$REPOSITORY-frontend:$IMAGE_TAG + - name: Build info + run: | + echo "IMAGE_TAG=$IMAGE_TAG" + echo "GITHUB_SHA=$GITHUB_SHA" From 72815676cee1b0465e8c0eab28ec5f8482b164fb Mon Sep 17 00:00:00 2001 From: Martin Varga Date: Mon, 10 Mar 2025 10:45:37 +0100 Subject: [PATCH 2/2] move variable to env in gh action --- .github/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index f8821d00..bb7d5a39 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -21,8 +21,8 @@ jobs: - name: Build, tag, and push CE images to Dockerhub env: BUILD_HASH: ${{ github.sha }} + IMAGE_TAG: ${{ github.ref_name }} run: | - IMAGE_TAG=${{ github.ref_name }} if [[ $GITHUB_REF_TYPE != "tag" ]]; then echo "Not a tag, exiting" exit 1