Skip to content

Commit

Permalink
GitHub workflow action: create docker images on release (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
jann0k authored Sep 4, 2024
1 parent f216a51 commit 7b16600
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
42 changes: 41 additions & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:

jobs:
publish:

runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -28,3 +27,44 @@ jobs:
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}

# test if username and password are correct (may still fail if no write access or wrong package name)
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build Docker/OCI images and publish to GH Container registry (ghcr.io)
run: |
mvn spring-boot:build-image -f get-server \
-s $GITHUB_WORKSPACE/settings.xml \
-Dmaven.test.skip=true \
-Dspring-boot.build-image.publish=true \
-Ddocker.publishRegistry.url=${REGISTRY} \
-Ddocker.publishRegistry.username=${USERNAME} \
-Ddocker.publishRegistry.password=${GITHUB_TOKEN} \
-Dspring-boot.build-image.imageName=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-get-server:${TAG}-${GITHUB_SHA} \
-Dspring-boot.build-image.tags=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-get-server:latest
mvn spring-boot:build-image -f put-server \
-s $GITHUB_WORKSPACE/settings.xml \
-Dmaven.test.skip=true \
-Dspring-boot.build-image.publish=true \
-Ddocker.publishRegistry.url=${REGISTRY} \
-Ddocker.publishRegistry.username=${USERNAME} \
-Ddocker.publishRegistry.password=${GITHUB_TOKEN} \
-Dspring-boot.build-image.imageName=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-put-server:${TAG}-${GITHUB_SHA} \
-Dspring-boot.build-image.tags=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-put-server:latest
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
# Note: git tag can contain more symbols than Container registry, allowed for docker tag:
# lowercase and uppercase letters, digits, underscores, periods, and hyphens.
# Note: imageName tag is built from git tag which can be different from module version
TAG: ${{ github.event.release.tag_name }}
# use open-eid Maven repo for dependencies download, see pom.xml
MAVEN_REPO: open-eid/cdoc2-capsule-server


12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,23 @@ by [defining repository variable](https://docs.github.com/en/actions/writing-wor

See [getting-started.md](getting-started.md) and [admin-guide.md](admin-guide.md)

### Running pre-built Docker/OCI images

Download `cdoc2-put-server` and `cdoc2-get-server` images from [open-eid Container registry](https://github.com/open-eid?ecosystem=container&tab=packages)

[ghcr.io login](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-with-a-personal-access-token-classic)

TODO: Configuring Docker images

## Releasing and versioning

See [VERSIONING.md](https://github.com/open-eid/cdoc2-java-ref-impl/blob/master/VERSIONING.md)

### GitHub release

[Create release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) on tag done by VERSIONING.md process. It will trigger `maven-release.yml` workflow that
will deploy Maven packages to GitHub Maven package repository.
[Create release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release) on tag done by [VERSIONING.md](https://github.com/open-eid/cdoc2-java-ref-impl/blob/master/VERSIONING.md) process.
It will trigger `maven-release.yml` workflow that will deploy Maven packages to GitHub Maven package repository
and build & publish Docker/OCI images.


## Related projects
Expand Down
7 changes: 7 additions & 0 deletions cdoc2-shared-crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.3</version>
</plugin>


</plugins>
</build>

Expand Down
13 changes: 13 additions & 0 deletions get-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,23 @@
<env>
<BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
<BP_SPRING_CLOUD_BINDINGS_DISABLED>true</BP_SPRING_CLOUD_BINDINGS_DISABLED>
<!--suppress UnresolvedMavenProperty -->
<BP_DEPENDENCY_MIRROR>${bp.dependency.mirror}</BP_DEPENDENCY_MIRROR>
<BPL_SPRING_CLOUD_BINDINGS_DISABLED>true</BPL_SPRING_CLOUD_BINDINGS_DISABLED>
</env>
<!--suppress UnresolvedMavenProperty -->
<tags>${spring-boot.build-image.tags}</tags>
</image>
<docker>
<publishRegistry>
<!--suppress UnresolvedMavenProperty -->
<url>${docker.publishRegistry.url}</url>
<!--suppress UnresolvedMavenProperty -->
<username>${docker.publishRegistry.username}</username>
<!--suppress UnresolvedMavenProperty -->
<password>${docker.publishRegistry.password}</password>
</publishRegistry>
</docker>
</configuration>
<executions>
<execution>
Expand Down
13 changes: 13 additions & 0 deletions put-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,23 @@
<env>
<BP_JVM_VERSION>${java.version}</BP_JVM_VERSION>
<BP_SPRING_CLOUD_BINDINGS_DISABLED>true</BP_SPRING_CLOUD_BINDINGS_DISABLED>
<!--suppress UnresolvedMavenProperty -->
<BP_DEPENDENCY_MIRROR>${bp.dependency.mirror}</BP_DEPENDENCY_MIRROR>
<BPL_SPRING_CLOUD_BINDINGS_DISABLED>true</BPL_SPRING_CLOUD_BINDINGS_DISABLED>
</env>
<!--suppress UnresolvedMavenProperty -->
<tags>${spring-boot.build-image.tags}</tags>
</image>
<docker>
<publishRegistry>
<!--suppress UnresolvedMavenProperty -->
<url>${docker.publishRegistry.url}</url>
<!--suppress UnresolvedMavenProperty -->
<username>${docker.publishRegistry.username}</username>
<!--suppress UnresolvedMavenProperty -->
<password>${docker.publishRegistry.password}</password>
</publishRegistry>
</docker>
</configuration>
<executions>
<execution>
Expand Down

0 comments on commit 7b16600

Please sign in to comment.