From 26fe696a8b3a9d693b4da59d5b16e442f826275d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Tue, 13 Feb 2024 22:20:23 +0100 Subject: [PATCH 1/5] Add build job for issuer front end. --- .../workflows/test-issuer-frontend-docker.yml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/test-issuer-frontend-docker.yml diff --git a/.github/workflows/test-issuer-frontend-docker.yml b/.github/workflows/test-issuer-frontend-docker.yml new file mode 100644 index 0000000..1f03b1d --- /dev/null +++ b/.github/workflows/test-issuer-frontend-docker.yml @@ -0,0 +1,43 @@ +name: Create and publish a Docker image for the issuer frontend. + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + # Only allow manual builds. + workflow_dispatch: # allows manual trigger + push: + branches: build-issuer-front-end # Temporary + +env: + REGISTRY: ghcr.io + IMAGE_NAME: issuer-front-end + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + # Uses the `docker/login-action` action to log in to the Container registry. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract tag from package.json + id: meta + run: echo "version=$(jq -r .version test-tools/issuer-front-end/package.json)" > "$GITHUB_OUTPUT" + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + file: ./test-tools/issuer-front-end/Dockerfile + push: true + platforms: linux/amd64 + tags: ${{ env.REGISTRY }}/concordium/${{ env.IMAGE_NAME}}:${{ steps.meta.outputs.version }} From f70b2b45e0c478a48be8caeedbb6db70e56c7f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Thu, 15 Feb 2024 13:09:37 +0100 Subject: [PATCH 2/5] Use dockerhub. --- .github/workflows/test-issuer-frontend-docker.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-issuer-frontend-docker.yml b/.github/workflows/test-issuer-frontend-docker.yml index 1f03b1d..0a45c59 100644 --- a/.github/workflows/test-issuer-frontend-docker.yml +++ b/.github/workflows/test-issuer-frontend-docker.yml @@ -1,3 +1,5 @@ +# This job builds and publishes a docker image for the test issuer frontend to +# the dockerhub image repository. name: Create and publish a Docker image for the issuer frontend. # Configures this workflow to run every time a change is pushed to the branch called `release`. @@ -8,16 +10,13 @@ on: branches: build-issuer-front-end # Temporary env: - REGISTRY: ghcr.io + REGISTRY: docker.io IMAGE_NAME: issuer-front-end jobs: build-and-push-image: runs-on: ubuntu-latest - # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. - permissions: - contents: read - packages: write + environment: testnet-builds steps: - name: Checkout repository uses: actions/checkout@v4 @@ -28,8 +27,8 @@ jobs: uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract tag from package.json id: meta run: echo "version=$(jq -r .version test-tools/issuer-front-end/package.json)" > "$GITHUB_OUTPUT" From a065d2f071df4ac7c3c6468ea9cd2d6044166157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Thu, 15 Feb 2024 13:24:29 +0100 Subject: [PATCH 3/5] Don't push duplicates. --- .github/workflows/test-issuer-frontend-docker.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-issuer-frontend-docker.yml b/.github/workflows/test-issuer-frontend-docker.yml index 0a45c59..335b63d 100644 --- a/.github/workflows/test-issuer-frontend-docker.yml +++ b/.github/workflows/test-issuer-frontend-docker.yml @@ -31,7 +31,18 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Extract tag from package.json id: meta - run: echo "version=$(jq -r .version test-tools/issuer-front-end/package.json)" > "$GITHUB_OUTPUT" + run: | + export VERSION=$(jq -r .version test-tools/issuer-front-end/package.json) + export FULL_IMAGE_TAG="${{ env.REGISTRY }}/concordium/$IMAGE_NAME:$VERSION" + echo "::notice FULL_IMAGE_TAG=${FULL_IMAGE_TAG}" + # Make sure the image does not exist. Abort if we can retrieve any metadata. + if docker manifest inspect docker.io/concordium/issuer-front-end:1.0.14 > /dev/null; then + echo "::error ${FULL_IMAGE_TAG} already exists" + exit 1 + else + # Store the full image tag into a tag variable for the following step. + echo "tag=${FULL_IMAGE_TAG}" > "$GITHUB_OUTPUT" + fi - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: @@ -39,4 +50,4 @@ jobs: file: ./test-tools/issuer-front-end/Dockerfile push: true platforms: linux/amd64 - tags: ${{ env.REGISTRY }}/concordium/${{ env.IMAGE_NAME}}:${{ steps.meta.outputs.version }} + tags: ${{ steps.meta.outputs.tag }} From 3e3db59782b7fd6d3fc3f963d8e19780c2036447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Thu, 15 Feb 2024 14:08:32 +0100 Subject: [PATCH 4/5] Add to README. --- ...docker.yml => release-test-issuer-frontend-docker.yml} | 6 +++--- issuer-front-end/README.md | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) rename .github/workflows/{test-issuer-frontend-docker.yml => release-test-issuer-frontend-docker.yml} (91%) diff --git a/.github/workflows/test-issuer-frontend-docker.yml b/.github/workflows/release-test-issuer-frontend-docker.yml similarity index 91% rename from .github/workflows/test-issuer-frontend-docker.yml rename to .github/workflows/release-test-issuer-frontend-docker.yml index 335b63d..e7143dc 100644 --- a/.github/workflows/test-issuer-frontend-docker.yml +++ b/.github/workflows/release-test-issuer-frontend-docker.yml @@ -2,12 +2,12 @@ # the dockerhub image repository. name: Create and publish a Docker image for the issuer frontend. -# Configures this workflow to run every time a change is pushed to the branch called `release`. on: - # Only allow manual builds. workflow_dispatch: # allows manual trigger + push: - branches: build-issuer-front-end # Temporary + tags: + - 'issuer-front-end/*.*.*' env: REGISTRY: docker.io diff --git a/issuer-front-end/README.md b/issuer-front-end/README.md index ca49aa0..3c84eee 100644 --- a/issuer-front-end/README.md +++ b/issuer-front-end/README.md @@ -80,3 +80,11 @@ docker run -it -d -p 8080:80 --name web issuer-front-end:3.0.0 ``` Open http://127.0.0.1:8080 in your browser. + +## Build and push to DockerHub + +To build the docker image and push to dockerhub use the +[test-issuer-front-end](https://github.com/Concordium/concordium-web3id/blob/main/.github/workflows/release-test-issuer-front-end.yaml) +job. + +The job will build the image, check that the version does not already exist, and push it. The job requires approval since it accesses secrets. From 2b3ed6efec7c3ca319a89e0d5ee1af07bf4040bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Bizjak?= Date: Thu, 15 Feb 2024 16:03:22 +0100 Subject: [PATCH 5/5] Fix typos. --- .github/workflows/release-test-issuer-frontend-docker.yml | 2 +- issuer-front-end/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-test-issuer-frontend-docker.yml b/.github/workflows/release-test-issuer-frontend-docker.yml index e7143dc..c4e7354 100644 --- a/.github/workflows/release-test-issuer-frontend-docker.yml +++ b/.github/workflows/release-test-issuer-frontend-docker.yml @@ -36,7 +36,7 @@ jobs: export FULL_IMAGE_TAG="${{ env.REGISTRY }}/concordium/$IMAGE_NAME:$VERSION" echo "::notice FULL_IMAGE_TAG=${FULL_IMAGE_TAG}" # Make sure the image does not exist. Abort if we can retrieve any metadata. - if docker manifest inspect docker.io/concordium/issuer-front-end:1.0.14 > /dev/null; then + if docker manifest inspect ${FULL_IMAGE_TAG} > /dev/null; then echo "::error ${FULL_IMAGE_TAG} already exists" exit 1 else diff --git a/issuer-front-end/README.md b/issuer-front-end/README.md index 3c84eee..72d4a72 100644 --- a/issuer-front-end/README.md +++ b/issuer-front-end/README.md @@ -84,7 +84,7 @@ Open http://127.0.0.1:8080 in your browser. ## Build and push to DockerHub To build the docker image and push to dockerhub use the -[test-issuer-front-end](https://github.com/Concordium/concordium-web3id/blob/main/.github/workflows/release-test-issuer-front-end.yaml) +[test-issuer-front-end](https://github.com/Concordium/concordium-web3id/blob/main/.github/workflows/release-test-issuer-front-end-docker.yaml) job. The job will build the image, check that the version does not already exist, and push it. The job requires approval since it accesses secrets.