From fdbdfc8fd6869447fa68b2d7927025a0dace60d6 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Wed, 6 Nov 2024 13:07:07 +0000 Subject: [PATCH] Add more to test action --- .github/actions/build/action.yml | 4 +++- .github/actions/test/action.yml | 25 +++++++++++++++++++++++++ .github/workflows/build.yml | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 0fde164..74c4161 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -24,7 +24,7 @@ inputs: outputs: tag: description: "The generated tag" - value: ${{ env.TAG }} + value: ${{ steps.generate-tags.outputs.tag }} runs: using: "composite" @@ -43,6 +43,7 @@ runs: run: echo "${{ inputs.github-token }}" | docker login ghcr.io -u $ --password-stdin shell: bash - name: Prepare image tag + id: generate-tags run: | IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${{ inputs.image-name }} # Change all uppercase to lowercase @@ -58,6 +59,7 @@ runs: echo "TAG=$VERSION" >> "$GITHUB_ENV" echo "MAJOR_VERSION=$VERSION_MAJOR" >> "$GITHUB_ENV" echo "MINOR_VERSION=$VERSION_MAJOR.$VERSION_MINOR" >> "$GITHUB_ENV" + echo "tag=$VERSION" >> "$GITHUB_OUTPUT" shell: bash - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index f398129..b13453e 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -4,6 +4,9 @@ inputs: application-repository: required: true type: string + service: + required: true + type: string image: required: true type: string @@ -14,10 +17,32 @@ inputs: runs: using: "composite" steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: ${{ inputs.application-repository }} + path: test - name: TODO run: | echo "inputs.application-repository: ${{ inputs.application-repository }}" echo "inputs.image: ${{ inputs.image }}" echo "inputs.image-tag: ${{ inputs.image-tag }}" + ls -alh + ls -alh test + shell: bash + - name: Update docker-compose.yml + run: | + cd test + cat docker-compose.yml + yq '(.services.app.build.args.IMAGE|="ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}")' docker-compose.yml > tmp.$$.yml && mv tmp.$$.yml docker-compose.yml + yq '(.services.app.build.args.IMAGE_TAG|="ghcr.io/${{ github.repository_owner }}/${{ inputs.image-tag }}")' docker-compose.yml > tmp.$$.yml && mv tmp.$$.yml docker-compose.yml + cat docker-compose.yml + PORT=$(yq '(.services.app.ports)' docker-compose.yml | sed -e 's/^\- \(.*\)\:.*$/\1/') + echo "PORT=$PORT" >> "$GITHUB_ENV" + docker compose up -d shell: bash + - name: Wait for healthcheck + uses: nev7n/wait_for_response@v1 + with: + url: http://localhost:${{ env.PORT }}/healthcheck/live/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c551cb0..2a46129 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,6 +43,7 @@ jobs: uses: ./.github/actions/test with: application-repository: https://github.com/nationalarchives/flask-application-template + service: app image: tna-python image-tag: ${{ steps.build.outputs.tag }}