Build and deploy docker images on develop #36
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
# This builds develop and deploys a snapshot to our repository. | |
# Will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
name: Build and deploy docker images | |
run-name: Build and deploy docker images on ${{ github.ref_name }} | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
MVNCMD: mvn -B -ntp -s ${{ github.workspace }}/.github/settings-istrepo.xml | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_ACTOR: ${{ github.actor }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: maven | |
maven-version: 3.8.7 | |
- name: Dump event context for debugging | |
continue-on-error: true # Debugging output only, and this annoyingly fails when the commit messge has a ( | |
run: | | |
echo '${{ github.event_name }} for ${{ github.ref_type }} ${{ github.ref_name }} or ${{ github.event.ref }}' | |
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push | |
echo 'github.event:' | |
echo '${{ toJSON(github.event) }}' | |
- name: Dump github context | |
continue-on-error: true # Debugging output only, and this annoyingly fails when the commit message has a ( | |
run: | | |
echo '${{ toJSON(github) }}' | |
- name: Set a master password | |
run: | | |
MASTERPWD=$(openssl rand -base64 25) | |
echo "<settingsSecurity> <master>$(mvn --encrypt-master-password "$MASTERPWD")</master></settingsSecurity>" > $HOME/.m2/settings-security.xml | |
# echo "MASTERPWD=\"$MASTERPWD\"" >> $GITHUB_ENV | |
# The master password isn't actually used, but the maven complains otherwise. | |
- name: Git & Maven Status | |
run: | | |
git status --untracked-files --ignored | |
git log -3 --no-color | |
$MVNCMD -version | |
git branch --show-current | |
- name: Mvn Effective POM | |
run: | | |
cd docker | |
$MVNCMD -P $(git branch --show-current) -N help:effective-pom | |
- name: Mvn Effective Settings | |
run: | | |
cd docker | |
$MVNCMD -P $(git branch --show-current) -N help:effective-settings | |
- name: Check docker status | |
run: | | |
docker info | |
docker version | |
docker images -a | |
docker ps -a | |
- name: Deploy with Maven | |
env: | |
DOCKERHUB_USER: composum | |
DOCKERHUB_PASSWD: ${{ secrets.DOCKERHUB_PASSWD }} | |
# We don't do docker pushes as we don't currently (as of 4/22) have an automatic solution for multi architecture builds | |
# Compare also https://github.com/actions/virtual-environments/issues/2187 (M1 support for github actions) | |
run: | | |
cd docker | |
$MVNCMD -P $(git branch --show-current),allplatforms deploy | |
- name: Check docker status | |
run: | | |
docker images -a | |
docker ps -a | |
sleep 300 | |
docker ps -a |