Skip to content

Commit

Permalink
WIP publish docker
Browse files Browse the repository at this point in the history
  • Loading branch information
gipo355 committed May 29, 2024
1 parent 5674265 commit 17cb77e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 28 deletions.
61 changes: 33 additions & 28 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
# https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
name: Publish Docker Image Workflow
on:
release:
Expand All @@ -12,35 +14,16 @@ jobs:
permissions:
contents: read
packages: write
name: Publish release Job
name: Publish Docker Job
steps:
- name: Checkout latest code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: ./.github/actions/ci-setup
name: Setup CI environment
- name: Publish artifact Step
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# for com.vanniktech.maven.publish.SonatypeHost
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }}
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | cut -d "v" -f2-) # 1.0.0-dev.1
echo "New version: ${NEW_VERSION}"
echo "Github username: ${GITHUB_ACTOR}"
./gradlew -Pversion=${NEW_VERSION} publishAndReleaseToMavenCentral --no-configuration-cache
./gradlew -Pversion=${NEW_VERSION} publishAllPublicationsToGitHubPackagesRepository
steps:
- name: Checkout latest code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Setup CI environment
uses: ./.github/actions/ci-setup
# build and deploy
- name: Build project
run: ./gradlew war
# prepare tags
# - name: Setup CI environment
# uses: ./.github/actions/ci-setup
# # build and deploy
# - name: Build project
# run: ./gradlew war
# prepare tags
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand All @@ -64,17 +47,39 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
# - name: Login to Docker Hub
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# TODO: remove context dump
- name: dump context for debugging
run: echo "$GITHUB_CONTEXT"
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: set version as env var
# run: echo "VERSION=${{ steps.meta.outputs.tags }}" >> $GITHUB_ENV
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | cut -d "v" -f2-) # 1.0.0-dev.1
echo "New version: ${NEW_VERSION}"
echo "Github username: ${GITHUB_ACTOR}"
./gradlew -Pversion=${NEW_VERSION} publishAndReleaseToMavenCentral --no-configuration-cache
./gradlew -Pversion=${NEW_VERSION} publishAllPublicationsToGitHubPackagesRepository
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,windows/amd64
push: true
push: ${{ github.event_name != 'pull_request' }}
# tags: ghcr.io/${{ github.repository_owner }}/its-battistar-express:latest
tags: ${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/tomcat-webapp-boilerplate:latest
# TODO: tag with release version
tags: ${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest, ${{ NEW_VERSION }}
labels: ${{ steps.meta.outputs.labels }}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
working with `./gradlew war`

compose up -d

# env vars

SEMGREP_APP_TOKEN
DOCKERHUB_TOKEN
DOCKERHUB_USERNAME
SNYK_TOKEN
PAT
CODECOV_TOKEN

0 comments on commit 17cb77e

Please sign in to comment.