diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b0cf42bf..079408a1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -54,12 +54,8 @@ jobs: - service: aries-endorser-api GIT_REPO_URL: hyperledger/aries-endorser-service DOCKER_FILE_PATH: Dockerfile.endorser # The docker path, file, is the relative path to the docker file from the root of the repo. - SOURCE_CONTEXT_DIR: endorser # The context dir, context, sets the context for the build. i.e. where the build will source files from - BASE_SOURCE_IMAGE_REGISTRY: artifacts.developer.gov.bc.ca/docker-remote/ - BASE_SOURCE_IMAGE_NAME: python - BASE_SOURCE_IMAGE_TAG: 3.10-slim-buster - REGISTRY_USERNAME_SECRET_NAME: ARTIFACTORY_USERNAME - REGISTRY_PASSWORD_SECRET_NAME: ARTIFACTORY_PASSWORD + SOURCE_CONTEXT_DIR: endorser # The context dir, context, sets the context for the build. i.e. where the build will source files from + outputs: aries-endorser-agent_digest: ${{ steps.digest.outputs.aries-endorser-agent_digest }} aries-endorser-backup_digest: ${{ steps.digest.outputs.aries-endorser-backup_digest }} @@ -72,29 +68,25 @@ jobs: uses: actions/checkout@v4 with: repository: ${{ matrix.GIT_REPO_URL }} - ref: ${{ github.event.tag }} + ref: ${{ github.event.tag }} if: ${{ github.event.tag != '' }} - name: Checkout uses: actions/checkout@v4 with: repository: ${{ matrix.GIT_REPO_URL }} - ref: ${{ github.event.branch }} + ref: ${{ github.event.branch }} if: ${{ github.event.tag == '' }} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Pull base image for proxy and Create Docker file if: contains(fromJSON('["aries-endorser-proxy"]'), matrix.service) run: | - if [[ -n "${BASE_SOURCE_IMAGE_REGISTRY}" ]]; then - docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $BASE_SOURCE_IMAGE_REGISTRY - BASE_IMAGE="${BASE_SOURCE_IMAGE_REGISTRY}${BASE_SOURCE_IMAGE_NAME}:${BASE_SOURCE_IMAGE_TAG}" - else docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $SOURCE_IMAGE_REGISTRY BASE_IMAGE=${SOURCE_IMAGE_REGISTRY}${SOURCE_IMAGE_NAME}:${SOURCE_IMAGE_TAG} - fi docker pull "${BASE_IMAGE}" mkdir ${context} && cd ${context} echo "FROM ${BASE_IMAGE}" > Dockerfile @@ -104,9 +96,6 @@ jobs: SOURCE_IMAGE_REGISTRY: ${{ matrix.SOURCE_IMAGE_REGISTRY }} SOURCE_IMAGE_NAME: ${{ matrix.SOURCE_IMAGE_NAME }} SOURCE_IMAGE_TAG: ${{ matrix.SOURCE_IMAGE_TAG }} - BASE_SOURCE_IMAGE_REGISTRY: ${{ matrix.BASE_SOURCE_IMAGE_REGISTRY }} - BASE_SOURCE_IMAGE_NAME: ${{ matrix.BASE_SOURCE_IMAGE_NAME }} - BASE_SOURCE_IMAGE_TAG: ${{ matrix.BASE_SOURCE_IMAGE_TAG }} REGISTRY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} REGISTRY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} @@ -133,26 +122,7 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha,value=latest - - - name: Update Docker base image and pull the base image if access is required - if: matrix.BASE_SOURCE_IMAGE_REGISTRY != '' && contains(fromJSON('["aries-endorser-db","aries-endorser-agent","aries-endorser-backup","aries-endorser-api","aries-endorser-proxy"]'), matrix.service) - run: | - if [[ -n "${REGISTRY_USERNAME}" ]]; then - docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $BASE_SOURCE_IMAGE_REGISTRY - fi - BASE_IMAGE="${BASE_SOURCE_IMAGE_REGISTRY}${BASE_SOURCE_IMAGE_NAME}:${BASE_SOURCE_IMAGE_TAG}" - sed -i -e "s;FROM .*;FROM ${BASE_IMAGE};g" "$file" - docker pull $BASE_IMAGE - - env: - context: ${{ matrix.SOURCE_CONTEXT_DIR }} - BASE_SOURCE_IMAGE_REGISTRY: ${{ matrix.BASE_SOURCE_IMAGE_REGISTRY }} - BASE_SOURCE_IMAGE_NAME: ${{ matrix.BASE_SOURCE_IMAGE_NAME }} - BASE_SOURCE_IMAGE_TAG: ${{ matrix.BASE_SOURCE_IMAGE_TAG }} - file: ${{ matrix.SOURCE_CONTEXT_DIR }}/${{ matrix.DOCKER_FILE_PATH }} - REGISTRY_USERNAME: ${{ secrets[matrix.REGISTRY_USERNAME_SECRET_NAME]}} - REGISTRY_PASSWORD: ${{ secrets[matrix.REGISTRY_PASSWORD_SECRET_NAME]}} - + - name: Build and push Docker image id: docker_build if: contains(fromJSON('["aries-endorser-agent","aries-endorser-backup","aries-endorser-api","aries-endorser-proxy"]'), matrix.service) @@ -170,7 +140,6 @@ jobs: if: contains(fromJSON('["aries-endorser-db"]'), matrix.service) run: | docker pull ${{ matrix.BUILDER_IMAGE }} - - name: Extract Values id: extract if: contains(fromJSON('["aries-endorser-db"]'), matrix.service) @@ -216,7 +185,6 @@ jobs: echo 'digest=${digest}' echo "${{ matrix.service }}_digest=${digest}" >> $GITHUB_OUTPUT cat $GITHUB_OUTPUT - deploy2dev: needs: build env: