Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
get rid of env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMassart committed Jan 7, 2022
1 parent f710de5 commit de94f18
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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 \
Expand All @@ -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
11 changes: 5 additions & 6 deletions actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion actions/pr-preview-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions actions/release-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
1 change: 0 additions & 1 deletion tests/.env

This file was deleted.

0 comments on commit de94f18

Please sign in to comment.