From 29f29839b57c69f2748f5d994f28cfb7e8c75d90 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Wed, 6 Nov 2024 12:40:37 +0000 Subject: [PATCH] Test action --- .github/actions/build/action.yml | 18 +++-- .github/actions/test/action.yml | 23 ++++++ .github/workflows/build.yml | 129 ++++++++++++++++--------------- 3 files changed, 98 insertions(+), 72 deletions(-) create mode 100644 .github/actions/test/action.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 86a8591..0fde164 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -7,9 +7,6 @@ inputs: docker-context: required: true type: string - dockerfile: - required: true - type: string base-image: required: false type: string @@ -24,12 +21,17 @@ inputs: required: true type: string +outputs: + tag: + description: "The generated tag" + value: ${{ env.TAG }} + runs: using: "composite" steps: - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: ${{ inputs.docker-context }}/${{ inputs.dockerfile }} + dockerfile: ${{ inputs.docker-context }}/Dockerfile ignore: SC1091,${{ inputs.ignore-linting-rules }} - name: ShellCheck run: | @@ -72,7 +74,7 @@ runs: BASE_IMAGE=${{ inputs.base-image }} BASE_IMAGE_TAG=${{ env.TAG }} TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} - TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/${{ inputs.dockerfile }} + TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile USER_IMAGE=${{ inputs.user-image }} push: true tags: ${{ env.IMAGE_ID }}:${{ env.TAG }} @@ -92,7 +94,7 @@ runs: BASE_IMAGE=${{ inputs.base-image }} BASE_IMAGE_TAG=${{ env.MAJOR_VERSION }} TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} - TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/${{ inputs.dockerfile }} + TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile USER_IMAGE=${{ inputs.user-image }} push: true tags: ${{ env.IMAGE_ID }}:${{ env.MAJOR_VERSION }} @@ -109,7 +111,7 @@ runs: BASE_IMAGE=${{ inputs.base-image }} BASE_IMAGE_TAG=${{ env.MINOR_VERSION }} TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} - TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/${{ inputs.dockerfile }} + TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile USER_IMAGE=${{ inputs.user-image }} push: true tags: ${{ env.IMAGE_ID }}:${{ env.MINOR_VERSION }} @@ -126,7 +128,7 @@ runs: BASE_IMAGE=${{ inputs.base-image }} BASE_IMAGE_TAG=latest TNA_DOCKER_IMAGE_VERSION=${{ env.TAG }} - TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/${{ inputs.dockerfile }} + TNA_DOCKER_IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}/blob/main/${{ inputs.docker-context }}/Dockerfile USER_IMAGE=${{ inputs.user-image }} push: true tags: ${{ env.IMAGE_ID }}:latest diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml new file mode 100644 index 0000000..f398129 --- /dev/null +++ b/.github/actions/test/action.yml @@ -0,0 +1,23 @@ +name: Test Docker image + +inputs: + application-repository: + required: true + type: string + image: + required: true + type: string + image-tag: + required: true + type: string + +runs: + using: "composite" + steps: + - name: TODO + run: | + echo "inputs.application-repository: ${{ inputs.application-repository }}" + echo "inputs.image: ${{ inputs.image }}" + echo "inputs.image-tag: ${{ inputs.image-tag }}" + shell: bash + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9379622..c551cb0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,6 @@ on: paths: - .github/** - docker/** - - tests/** concurrency: group: ${{ github.ref }}-publish @@ -33,76 +32,78 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Build and push + id: build uses: ./.github/actions/build with: image-name: tna-python docker-context: docker/tna-python - dockerfile: Dockerfile ignore-linting-rules: DL3002,DL3006 github-token: ${{ secrets.GITHUB_TOKEN }} - - python-root: - name: Python (root) - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build and push - uses: ./.github/actions/build + - name: Test + uses: ./.github/actions/test with: - image-name: tna-python-root - docker-context: docker/tna-python - user-image: root - dockerfile: Dockerfile - ignore-linting-rules: DL3002,DL3006 - github-token: ${{ secrets.GITHUB_TOKEN }} + application-repository: https://github.com/nationalarchives/flask-application-template + image: tna-python + image-tag: ${{ steps.build.outputs.tag }} - python-django: - name: Python Django - needs: python - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build and push - uses: ./.github/actions/build - with: - image-name: tna-python-django - base-image: ghcr.io/nationalarchives/tna-python - docker-context: docker/tna-python-django - dockerfile: Dockerfile - github-token: ${{ secrets.GITHUB_TOKEN }} + # python-root: + # name: Python (root) + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Build and push + # uses: ./.github/actions/build + # with: + # image-name: tna-python-root + # docker-context: docker/tna-python + # user-image: root + # ignore-linting-rules: DL3002,DL3006 + # github-token: ${{ secrets.GITHUB_TOKEN }} - python-django-root: - name: Python Django (root) - needs: python-root - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build and push - uses: ./.github/actions/build - with: - image-name: tna-python-django-root - base-image: ghcr.io/nationalarchives/tna-python-root - docker-context: docker/tna-python-django - dockerfile: Dockerfile - ignore-linting-rules: DL3002 - github-token: ${{ secrets.GITHUB_TOKEN }} + # python-django: + # name: Python Django + # needs: python + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Build and push + # uses: ./.github/actions/build + # with: + # image-name: tna-python-django + # base-image: ghcr.io/nationalarchives/tna-python + # docker-context: docker/tna-python-django + # github-token: ${{ secrets.GITHUB_TOKEN }} - python-dev: - name: Python Dev - needs: python-root - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build and push - uses: ./.github/actions/build - with: - image-name: tna-python-dev - base-image: ghcr.io/nationalarchives/tna-python-root - docker-context: docker/tna-python-dev - dockerfile: Dockerfile - ignore-linting-rules: DL3002,DL3008 - github-token: ${{ secrets.GITHUB_TOKEN }} + # python-django-root: + # name: Python Django (root) + # needs: python-root + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Build and push + # uses: ./.github/actions/build + # with: + # image-name: tna-python-django-root + # base-image: ghcr.io/nationalarchives/tna-python-root + # docker-context: docker/tna-python-django + # ignore-linting-rules: DL3002 + # github-token: ${{ secrets.GITHUB_TOKEN }} + + # python-dev: + # name: Python Dev + # needs: python-root + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Build and push + # uses: ./.github/actions/build + # with: + # image-name: tna-python-dev + # base-image: ghcr.io/nationalarchives/tna-python-root + # docker-context: docker/tna-python-dev + # ignore-linting-rules: DL3002,DL3008 + # github-token: ${{ secrets.GITHUB_TOKEN }}