Skip to content

Commit

Permalink
Fix GH workflow for maven deploy (#10)
Browse files Browse the repository at this point in the history
*    fix maven deploy on release
*   disable attestation generation for cdoc2-server-liquibase images (generates broken images)
*  try to fix building for push (builds not triggered for push currently)
  • Loading branch information
jann0k authored Sep 20, 2024
1 parent a5f40d3 commit a907c7b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}

# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
#subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-name: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
# Broken: generates images with sha256, that fail to start with "unsupported media type application/vnd.oci.empty.v1+json"
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# #subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-name: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true

14 changes: 13 additions & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@ jobs:
distribution: 'temurin'
settings-path: ${{ github.workspace }} # location for the settings.xml file

# Maven versioning is broken in so many ways (Maven is older than git). In semver you want to increase version only when there
# are changes in module. Maven forces to change submodule version even when only change was main pom version change
# Here: deploy for each submodule is necessary
# to deploy submodules even when main module didn't change
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
run: |
mvn deploy -s $GITHUB_WORKSPACE/settings.xml
mvn -f cdoc2-shared-crypto deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
mvn -f server-openapi deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
mvn -f server-db deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
mvn -f server-common deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
mvn -f put-server deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
mvn -f get-server deploy -Dmaven.test.skip=true -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
MAVEN_REPO: open-eid/cdoc2-capsule-server # maven repo to download dependencies

# 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
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,26 @@ env:
jobs:
fork_setup:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true }}

outputs:
base_repo: ${{ steps.base_repo.outputs.name }}
is_fork: ${{ steps.is_fork.outputs.is_fork }}

steps:
- id: base_repo
run: echo "name=${{github.event.pull_request.base.repo.full_name}}" >> "$GITHUB_OUTPUT"
run: |
if [ ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true }} ]; then
echo "name=${{github.event.pull_request.base.repo.full_name}}" >> "$GITHUB_OUTPUT"
else
echo "name=${{ github.event.repo.name }}" >> "$GITHUB_OUTPUT"
fi
- id: is_fork
run: echo "is_fork=true" >> "$GITHUB_OUTPUT"
run: |
if [ ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true }} ]; then
echo "is_fork=true" >> "$GITHUB_OUTPUT"
else
echo "is_fork=false" >> "$GITHUB_OUTPUT"
fi
build:
runs-on: ubuntu-latest
Expand All @@ -56,6 +66,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
IS_FORK: ${{needs.fork_setup.outputs.is_fork}}
BASE_REPO: ${{needs.fork_setup.outputs.base_repo}}
MAVEN_REPO: ${{vars.MAVEN_REPO}} # set as repository variable: open-eid/cdoc2-capsule-server


# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
Expand Down
2 changes: 1 addition & 1 deletion get-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
</executions>
<configuration>
<failIfNotMatch>false</failIfNotMatch>
<userProperty>true</userProperty>
<userProperty>false</userProperty>
<!--skip>true</skip-->
</configuration>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
</executions>
<configuration>
<failIfNotMatch>false</failIfNotMatch>
<userProperty>true</userProperty>
<userProperty>false</userProperty>
<!--skip>true</skip-->
</configuration>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion put-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@
</executions>
<configuration>
<failIfNotMatch>false</failIfNotMatch>
<userProperty>true</userProperty>
<userProperty>false</userProperty>
<!--skip>true</skip-->
</configuration>
</plugin>
Expand Down

0 comments on commit a907c7b

Please sign in to comment.