Deploy #63
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
tags: | |
- "*" | |
workflow_dispatch: | |
jobs: | |
deployment: | |
permissions: | |
packages: write | |
environment: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 11 | |
distribution: 'temurin' | |
cache: 'maven' | |
server-id: openconext-releases | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
- name: Set up cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Determine the version | |
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT | |
id: versioncheck | |
- name: Exit when workflow_dispatch is triggered, and the version does not contain SNAPSHOT in it's name | |
run: | | |
echo "Only SNAPSHOT releases can be triggered with the workflow_dispatch" | |
exit 1 | |
if: github.event_name == 'workflow_dispatch' && ( !endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) | |
- name: Exit when a production build is triggered, and the github tag is not the same as the version in pom.xml | |
run: | | |
echo "Project version ${{ steps.versioncheck.outputs.version }} does not match git tag ${{ github.ref_name }}" | |
exit 1 | |
if: github.event_name != 'workflow_dispatch' && steps.versioncheck.outputs.version != github.ref_name | |
- name: Set up JDK 11 for snapshots | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "11" | |
distribution: "temurin" | |
cache: "maven" | |
server-id: openconext-snapshots | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
if: ( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) | |
- name: Set up JDK 11 for releases | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "11" | |
distribution: "temurin" | |
cache: "maven" | |
server-id: openconext-releases | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
if: ${{!( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) }} | |
- name: Deploy with Maven | |
run: mvn --batch-mode deploy -DskipTests | |
env: | |
MAVEN_USERNAME: ${{ secrets.BUILD_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.BUILD_PASSWORD }} | |
- name: Build Changelog | |
id: changelog | |
uses: ardalanamini/auto-changelog@v3 | |
with: | |
default-commit-type: New Features | |
if: github.event_name != 'workflow_dispatch' | |
- name: Create release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: false | |
prerelease: true | |
release_name: Release ${{ github.ref_name }} | |
tag_name: ${{ github.ref_name }} | |
body: | | |
${{ steps.changelog.outputs.changelog }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
if: github.event_name != 'workflow_dispatch' | |
- name: Check account-gui zip existence | |
id: check_file_account_gui | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: "/home/runner/work/OpenConext-myconext/OpenConext-myconext/account-gui/target/account-gui-${{ github.ref_name }}.zip" | |
- name: Upload account-gui zip to github release | |
if: steps.check_file_account_gui.outputs.files_exists == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: "/home/runner/work/OpenConext-myconext/OpenConext-myconext/account-gui/target/account-gui-${{ github.ref_name }}.zip" | |
asset_name: account-gui-${{ github.ref_name }}.zip | |
asset_content_type: application/zip | |
- name: Check myconext-gui zip existence | |
id: check_file_myconext_gui | |
uses: andstor/file-existence-action@v1 | |
with: | |
files: "/home/runner/work/OpenConext-myconext/OpenConext-myconext/myconext-gui/target/myconext-gui-${{ github.ref_name }}.zip" | |
- name: Upload myconext-gui zip to github release | |
if: steps.check_file_myconext_gui.outputs.files_exists == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: /home/runner/work/OpenConext-myconext/OpenConext-myconext/myconext-gui/target/myconext-gui-${{ github.ref_name }}.zip | |
asset_name: myconext-gui-${{ github.ref_name }}.zip | |
asset_content_type: application/zip | |
- name: Check myconext-server jar existence | |
id: check_file_myconext_server | |
uses: andstor/file-existence-action@v1 | |
with: | |
files: "/home/runner/work/OpenConext-myconext/OpenConext-myconext/myconext-server/target/myconext-server-${{ github.ref_name }}.jar" | |
- name: Upload myconext-server jar to github release | |
if: steps.check_file_myconext_server.outputs.files_exists == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: /home/runner/work/OpenConext-myconext/OpenConext-myconext/myconext-server/target/myconext-server-${{ github.ref_name }}.jar | |
asset_name: myconext-server-${{ github.ref_name }}.jar | |
asset_content_type: application/zip | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for MyConext GUI Docker | |
id: meta_account_gui | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/openconext/openconext-myconext/myconext-gui | |
flavor: | | |
latest=false | |
tags: | | |
type=ref,event=tag | |
type=raw,event=tag,value=latest | |
type=raw,event=workflow_dispatch,value=snapshot | |
type=semver,pattern={{version}},value=${{ steps.versioncheck.outputs.version }} | |
type=sha | |
- name: Extract metadata (tags, labels) for acount GUI Docker | |
id: meta_server_gui | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/openconext/openconext-myconext/account-gui | |
flavor: | | |
latest=false | |
tags: | | |
type=ref,event=tag | |
type=raw,event=tag,value=latest | |
type=raw,event=workflow_dispatch,value=snapshot | |
type=semver,pattern={{version}},value=${{ steps.versioncheck.outputs.version }} | |
type=sha | |
- name: Extract metadata (tags, labels) for Server Docker | |
id: meta_server | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/openconext/openconext-myconext/myconext-server | |
flavor: | | |
latest=false | |
tags: | | |
type=ref,event=tag | |
type=raw,event=tag,value=latest | |
type=raw,event=workflow_dispatch,value=snapshot | |
type=semver,pattern={{version}},value=${{ steps.versioncheck.outputs.version }} | |
type=sha | |
- name: Build and push the account gui image | |
uses: docker/build-push-action@v5 | |
with: | |
context: account-gui | |
file: account-gui/docker/Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta_account_gui.outputs.tags }} | |
labels: ${{ steps.meta_account_gui.outputs.labels }} | |
- name: Build and push the myconext gui image | |
uses: docker/build-push-action@v5 | |
with: | |
context: myconext-gui | |
file: myconext-gui/docker/Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta_server_gui.outputs.tags }} | |
labels: ${{ steps.meta_server_gui.outputs.labels }} | |
- name: Build and push the server image | |
uses: docker/build-push-action@v5 | |
with: | |
context: myconext-server | |
file: myconext-server/docker/Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta_server.outputs.tags }} | |
labels: ${{ steps.meta_server.outputs.labels }} |