Build #1642
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: Build | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '0 4 * * *' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build: | |
name: Build & Deploy | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
outputs: | |
xoom_version: ${{ steps.version.outputs.xoom_version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '8' | |
distribution: 'zulu' | |
cache: 'maven' | |
- name: Cache Node packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
target/node | |
src/main/frontend/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('src/main/frontend/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node | |
- name: Determine version | |
id: version | |
run: echo "xoom_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT | |
- name: Build with Maven | |
run: mvn --batch-mode --update-snapshots package -Pfrontend -Pgithub-releases | |
- name: Publish artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: JARs | |
path: target/*.jar | |
- name: Trigger downstream builds | |
if: startsWith(github.ref, 'refs/tags/') | |
run: .github/trigger_deps.sh | |
env: | |
RELEASE_GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} | |
- name: Notify discord | |
if: always() && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository_owner == 'vlingo' | |
uses: 'Ilshidur/action-discord@0.3.2' | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
DISCORD_USERNAME: Bob the Builder | |
DISCORD_EMBEDS: '[{"title":"Build ${{ job.status }}", "description":"[${{ github.repository }}:${{ steps.version.outputs.xoom_version }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})","author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "${{ github.server_url }}/${{ github.actor }}"},"color":"${{ job.status == ''success'' && ''65280'' || ''16711680'' }}"}]' | |
- name: Cleanup | |
run: rm -rf ~/.m2/repository/io/vlingo | |
docker: | |
name: Build Docker image | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Determine the version | |
id: version | |
run: | | |
DOCKER_IMAGE=vlingo/xoom-schemata | |
VERSION=snapshot | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
TAGS="${DOCKER_IMAGE}:snapshot,${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${VERSION}" | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "tags=${TAGS}" >> $GITHUB_OUTPUT | |
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT | |
echo "push=${{ (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') && github.repository_owner == 'vlingo' }}" >> $GITHUB_OUTPUT | |
- uses: actions/download-artifact@v3 | |
with: | |
name: JARs | |
path: target/ | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
if: steps.version.outputs.push == 'true' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build & Push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: ${{ steps.version.outputs.push }} | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.version.outputs.tags }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ steps.version.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
- name: Notify discord | |
if: failure() && steps.version.outputs.push == 'true' | |
uses: 'Ilshidur/action-discord@0.3.2' | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
DISCORD_USERNAME: Suzi the Publisher | |
DISCORD_EMBEDS: '[{"title":"Docker Image Build ${{ job.status }}", "description":":rocket: [${{ github.repository }}:${{ steps.version.outputs.xoom_version }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})","author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "${{ github.server_url }}/${{ github.actor }}"},"color":"${{ job.status == ''success'' && ''65280'' || ''16711680'' }}"}]' |