diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7b6b1b6..1d04915 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,12 +25,24 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set image ID and TAG + shell: sh + id: generate_image_info + run: | + IMAGE_ID=$REGISTRY/${{ github.repository_owner }}/$IMAGE_NAME + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # output image id + echo "::set-output name=id::$IMAGE_ID" + # output image tag + echo "::set-output name=tag::${GITHUB_REF#refs/*/}" + - name: Build image shell: sh run: | docker build . \ --tag $IMAGE_NAME \ - --build-arg VERSION="${GITHUB_REF#refs/*/}" \ + --build-arg VERSION="${{ steps.generate_image_info.outputs.tag }}" \ --build-arg REVISION="${GITHUB_SHA}" \ --build-arg GITHUB_WORKFLOW="${GITHUB_WORKFLOW}" \ --build-arg GITHUB_RUN_ID="${GITHUB_RUN_ID}" @@ -39,7 +51,7 @@ jobs: shell: sh run: | docker run --rm \ - --env-file ./tests/.env \ + -e VERSION=test \ -v ${PWD}:/workspace \ -w /workspace \ $IMAGE_NAME \ @@ -54,31 +66,21 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set image name - shell: sh - run: | - IMAGE_ID=$REGISTRY/${{ github.repository_owner }}/$IMAGE_NAME - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV - - name: Push latest shell: sh run: | - docker tag $IMAGE_NAME $IMAGE_ID:$IMAGE_LATEST_TAG - docker push $IMAGE_ID:$IMAGE_LATEST_TAG + docker tag $IMAGE_NAME ${{ steps.generate_image_info.outputs.id }}:$IMAGE_LATEST_TAG + docker push ${{ steps.generate_image_info.outputs.id }}:$IMAGE_LATEST_TAG - name: Push tagged release if: github.event_name == 'release' && github.event.action == 'published' shell: sh run: | - IMAGE_TAG=${GITHUB_REF#refs/*/} - docker tag $IMAGE_NAME $IMAGE_ID:$IMAGE_TAG - docker push $IMAGE_ID:$IMAGE_TAG + docker tag $IMAGE_NAME ${{ steps.generate_image_info.outputs.id }}:${{ steps.generate_image_info.outputs.tag }} + docker push ${{ steps.generate_image_info.outputs.id }}:${{ steps.generate_image_info.outputs.tag }} - name: Test building doc using our action uses: ConsenSys/doctools.action-builder/actions/build@main with: SITE_ROOT: 'https://example.org' #fake site, just testing but cannot be empty - ENV_FILE: tests/.env MKDOCS_CONFIG: /workspace/tests/mkdocs.yml diff --git a/actions/build/action.yml b/actions/build/action.yml index 3910843..0a7167a 100644 --- a/actions/build/action.yml +++ b/actions/build/action.yml @@ -14,10 +14,6 @@ inputs: description: 'doc version to build' required: false default: latest - ENV_FILE: - description: 'doc env file for mkdocs' - required: false - default: './.env' MKDOCS_CONFIG: description: 'Path to the mkdocs.yml file. Default is [project root]/mkdocs.yml' required: false @@ -26,6 +22,10 @@ inputs: description: 'Path to the output directory. Default is site' required: false default: 'site' + DOCTOOLS_IMAGE_VERSION: + description: 'Version of the image to use for building. Default is latest' + required: false + default: 'latest' runs: using: "composite" @@ -38,10 +38,9 @@ runs: -e SITE_URL="${{ inputs.SITE_ROOT }}/${{ inputs.LANGUAGE }}/${{ inputs.VERSION }}/" \ -e VERSION="${{ inputs.VERSION }}" \ -e LANGUAGE="${{ inputs.LANGUAGE }}" \ - --env-file ${{ inputs.ENV_FILE }} \ -v ${PWD}:/workspace/ \ -w /workspace/ \ - ghcr.io/consensys/doctools-builder:${DOCTOOLS_IMAGE_VERSION:=latest} \ + ghcr.io/consensys/doctools-builder:${{ inputs.DOCTOOLS_IMAGE_VERSION }} \ build -s \ -d ${{ inputs.OUTPUT_DIR }} \ --config-file ${{ inputs.MKDOCS_CONFIG }} diff --git a/actions/pr-preview-publish/action.yml b/actions/pr-preview-publish/action.yml index 3a2c480..081cc4b 100644 --- a/actions/pr-preview-publish/action.yml +++ b/actions/pr-preview-publish/action.yml @@ -12,7 +12,7 @@ inputs: runs: using: "composite" steps: - - name: Get additional Github env vars + - name: Get additional Github env vars # vars from Github env, can not be modified by users uses: FranzDiebold/github-env-vars-action@b9b3a88cfa3ad9bde40c291143c28f918e2d1668 #v2.3.0 - name: generate PR slug diff --git a/actions/release-publish/action.yml b/actions/release-publish/action.yml index e45773c..1c5edc1 100644 --- a/actions/release-publish/action.yml +++ b/actions/release-publish/action.yml @@ -29,17 +29,17 @@ inputs: runs: using: "composite" steps: - - name: Set TAG env vars + - name: Set TAG shell: sh - run: | - echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + id: generate_tag + run: echo "::set-output name=tag::${GITHUB_REF#refs/*/}" - name: Build doc uses: ConsenSys/doctools.action-builder/actions/build@main with: SITE_ROOT: ${{ inputs.SITE_ROOT }} LANGUAGE: ${{ inputs.LANGUAGE }} - VERSION: ${{ env.TAG }} + VERSION: ${{ steps.generate_tag.outputs.tag }} - name: Publish stable version to AWS uses: ConsenSys/doctools.action-builder/actions/publish-aws@main @@ -61,4 +61,4 @@ runs: AWS_S3_BUCKET: ${{ inputs.AWS_S3_BUCKET }} PROJECT: ${{ inputs.PROJECT }} LANGUAGE: ${{ inputs.LANGUAGE }} - VERSION: ${{ env.TAG }} + VERSION: ${{ steps.generate_tag.outputs.tag }} diff --git a/tests/.env b/tests/.env deleted file mode 100644 index 60f90bd..0000000 --- a/tests/.env +++ /dev/null @@ -1 +0,0 @@ -VERSION=test