diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a294e4..f410a98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,7 @@ jobs: install: true - name: Read Pharo-sync-commit file and set to env variable - run: | - bin/export-sync-commit.sh - echo "SHA_OR_BRANCH=${SHA_OR_BRANCH}" >> $GITHUB_ENV + run: bin/export-sync-commit.sh - name: Build Docker image and store in cache uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 43c1cc9..26179de 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,9 +10,22 @@ permissions: contents: write jobs: + prepare: + runs-on: ubuntu-22.04 + outputs: + SHA_OR_BRANCH: ${{ steps.export-sync-commit.outputs.SHA_OR_BRANCH }} + steps: + - name: Checkout code + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + + - name: Export sync commit + id: export-sync-commit + run: bin/export-sync-commit.sh + build-and-push-image: if: github.repository_owner == 'exercism' # Stops this job from running on forks. uses: exercism/github-actions/.github/workflows/docker-build-push-image.yml@main + needs: prepare secrets: AWS_ACCOUNT_ID: ${{secrets.AWS_ACCOUNT_ID}} AWS_REGION: ${{secrets.AWS_REGION}} @@ -20,3 +33,4 @@ jobs: AWS_ECR_SECRET_ACCESS_KEY: ${{secrets.AWS_ECR_SECRET_ACCESS_KEY}} DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} DOCKERHUB_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} + DOCKER_BUILD_ARGS: SHA_OR_BRANCH=${{needs.prepare.outputs.SHA_OR_BRANCH}} diff --git a/bin/export-sync-commit.sh b/bin/export-sync-commit.sh index 28d970a..253d15f 100755 --- a/bin/export-sync-commit.sh +++ b/bin/export-sync-commit.sh @@ -1,3 +1,8 @@ #!/usr/bin/env sh export SHA_OR_BRANCH=$(sed -n '3p' Pharo-sync-commit) + +if [ -n "$GITHUB_ACTIONS" ]; then + echo "SHA_OR_BRANCH=${SHA_OR_BRANCH}" >> $GITHUB_ENV + echo "SHA_OR_BRANCH=${SHA_OR_BRANCH}" >> $GITHUB_OUTPUT +fi diff --git a/bin/run-in-docker.sh b/bin/run-in-docker.sh index ea6e06e..a436c3e 100755 --- a/bin/run-in-docker.sh +++ b/bin/run-in-docker.sh @@ -28,7 +28,7 @@ fi bin/export-sync-commit.sh # build docker image -docker build --build-arg SHA_OR_BRANCH="${SHA_OR_BRANCH}" --rm -t exercism/pharo-smalltalk-test-runner . +docker build --build-arg SHA_OR_BRANCH="${SHA_OR_BRANCH}" --rm --no-cache -t exercism/pharo-smalltalk-test-runner . # Create output directory if it doesn't exist output_dir="$3" diff --git a/bin/run-tests-in-docker.sh b/bin/run-tests-in-docker.sh index b989d0b..b02ed86 100755 --- a/bin/run-tests-in-docker.sh +++ b/bin/run-tests-in-docker.sh @@ -16,7 +16,7 @@ set -e # Build the Docker image -docker build --build-arg GROUP_NAMES=testRunnerTests --rm -t exercism/pharo-smalltalk-test-runner . +docker build --build-arg GROUP_NAMES=testRunnerTests --rm --load -t exercism/pharo-smalltalk-test-runner . # Run the Docker image using the settings mimicking the production environment docker run \