Skip to content

Commit

Permalink
Update GitHub Actions workflow and Docker build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sofusalbertsen committed Jan 31, 2024
1 parent 0eef5f7 commit 6a16d52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions ci/build-docker.sh
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion ci/push-docker.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6a16d52

Please sign in to comment.