From 6a16d52ace2a1ced8fd6164bd476b8ff6d23937b Mon Sep 17 00:00:00 2001 From: Sofus Albertsen Date: Wed, 31 Jan 2024 10:01:16 +0100 Subject: [PATCH] Update GitHub Actions workflow and Docker build scripts --- .github/workflows/main.yaml | 4 +++- ci/build-docker.sh | 7 ++++--- ci/push-docker.sh | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 3cce0c1d1..14e616be4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -3,7 +3,7 @@ on: push env: # Set the secret as an input docker_username: ${{ github.actor }} docker_password: ${{ secrets.GITHUB_TOKEN }} - GIT_COMMIT: ${{ github.sha }} + GIT_COMMIT: "${{ github.sha }} ::8" jobs: Build: runs-on: ubuntu-latest @@ -15,6 +15,8 @@ jobs: run: ci/build-app.sh - name: Test run: ci/unit-test-app.sh + - name: ls + run: ls -la ci - uses: actions/upload-artifact@v4 with: name: code diff --git a/ci/build-docker.sh b/ci/build-docker.sh index c10c1ff6a..6378f78d3 100755 --- a/ci/build-docker.sh +++ b/ci/build-docker.sh @@ -1,4 +1,5 @@ #!/bin/bash -[[ -z "${GIT_COMMIT}" ]] && Tag='local' || Tag="${GIT_COMMIT::8}" -[[ -z "${docker_username}" ]] && DockerRepo='' || DockerRepo="ghcr.io/${docker_username}/" -docker build -t "${DockerRepo}micronaut-app:latest" -t "${DockerRepo}micronaut-app:1.0-$Tag" app/ +[[ -z "${GIT_COMMIT}" ]] && Tag='local' || Tag="${GIT_COMMIT::8}" +REPO="ghcr.io/${{ github.actor }}/" +echo "${REPO}" +docker build -t "${REPO}micronaut-app:latest" -t "${REPO}micronaut-app:1.0-$Tag" app/ diff --git a/ci/push-docker.sh b/ci/push-docker.sh index bb7836324..df9b629b1 100755 --- a/ci/push-docker.sh +++ b/ci/push-docker.sh @@ -1,5 +1,5 @@ #!/bin/bash -echo "$docker_password" | docker login ghcr.io --username "$docker_username" --password-stdin +echo "$secrets.GITHUB_TOKEN" | docker login ghcr.io --username "${{ github.actor }}" --password-stdin docker push "ghcr.io/$docker_username/micronaut-app:1.0-${GIT_COMMIT::8}" docker push "ghcr.io/$docker_username/micronaut-app:latest" & wait