From 01d7e8dc6a3cdb221603bd0c69a436d7302e2056 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo <71768+gionn@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:48:03 +0200 Subject: [PATCH] OPSEXP-2737 Some minor but necessary workflow improvement (#11) --- .github/dependabot.yml | 10 ++++++ .github/workflows/build_and_test.yml | 46 ++++++++++++++++++---------- scripts/fetch-artifact.sh | 3 +- 3 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..2390d8c8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 523a55a2..711c56ce 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,31 +1,41 @@ name: Build, Run and Test Docker Image -on: [push] +on: + push: + branches: + - main + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name || github.run_id }} + cancel-in-progress: true jobs: build-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7 + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Setup .netrc + - name: Setup nexus authentication run: | echo "machine nexus.alfresco.com" >> ~/.netrc echo "login ${{ secrets.NEXUS_USERNAME }}" >> ~/.netrc echo "password ${{ secrets.NEXUS_PASSWORD }}" >> ~/.netrc - name: Fetch artifacts from nexus - run: ${{ github.workspace }}/scripts/fetch-artifact.sh - working-directory: ${{ github.workspace }} + run: ./scripts/fetch-artifact.sh - name: Set up QEMU - uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # 3.1.0 + uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # v3.1.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@2ad185228a349d19414702819e06df9fa4314287 # 3.4.0 + uses: docker/setup-buildx-action@2ad185228a349d19414702819e06df9fa4314287 # v3.4.0 - - name: Login to Docker Hub - uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # 3.2.0 + - name: Login to Quay.io + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 with: registry: quay.io username: ${{ secrets.QUAY_USERNAME }} @@ -34,18 +44,20 @@ jobs: - name: Bake Docker images uses: docker/bake-action@eac74531aa56a9266bfedfe5edb6b851ce2cca2b # v5.4.0 - - name: Show all images + - name: Show all built images run: docker images - - name: Docker save the images produced by the bake action with the name consisting alfresco + - name: Docker save all baked images whose name include `alfresco` run: | docker save -o /tmp/alfresco-docker-images.tar $(docker images --format "{{.Repository}}:{{.Tag}}" | grep alfresco) - - name: Upload image as a tar for next job - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # 4.3.4 + - name: Upload images as artifact + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 with: - name: ${{ github.run_number }} + name: docker-images path: /tmp/alfresco-docker-images.tar + retention-days: 1 + compression-level: 0 compose-test: name: compose-test ${{ matrix.docker-compose-file }} @@ -56,13 +68,13 @@ jobs: docker-compose-file: [docker-compose.yml, docker-compose-components.yml] steps: - name: Set up Docker Buildx - uses: docker/setup-buildx-action@2ad185228a349d19414702819e06df9fa4314287 # 3.4.0 + uses: docker/setup-buildx-action@2ad185228a349d19414702819e06df9fa4314287 # v3.4.0 - name: Download artifacts - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: path: /tmp - name: "${{ github.run_number }}" + name: docker-images - name: Load Docker images run: | diff --git a/scripts/fetch-artifact.sh b/scripts/fetch-artifact.sh index dd7cff59..fa651327 100755 --- a/scripts/fetch-artifact.sh +++ b/scripts/fetch-artifact.sh @@ -19,6 +19,7 @@ for i in $(find . -name artifacts.json -mindepth 2); do ARTIFACT_BASEURL="https://nexus.alfresco.com/nexus/repository/${ARTIFACT_REPO}" echo "Downloading $ARTIFACT_GROUP:$ARTIFACT_NAME $ARTIFACT_VERSION from $ARTIFACT_BASEURL" wget "${ARTIFACT_BASEURL}/${ARTIFACT_GROUP//\./\/}/${ARTIFACT_NAME}/${ARTIFACT_VERSION}/${ARTIFACT_NAME}-${ARTIFACT_VERSION}${ARTIFACT_EXT}" \ - -O ${ARTIFACT_PATH}/${ARTIFACT_NAME}-${ARTIFACT_VERSION}${ARTIFACT_EXT} + -O ${ARTIFACT_PATH}/${ARTIFACT_NAME}-${ARTIFACT_VERSION}${ARTIFACT_EXT} \ + --no-verbose done done