Skip to content

Commit

Permalink
update container structure test, trigger workflow on tag push
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-gilber committed Oct 30, 2023
1 parent 2a15b9f commit 2fa8176
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ name: Publish Container Image

# Events: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
on:
# Trigger Workflow when a release is published
# release payload: https://docs.github.com/en/webhooks/webhook-events-and-payloads#release
release:
types: [published]
# for testing
# Trigger Workflow on push event
push:
branches:
- main # When `latest` image tag is published when default branch is updated
- publish-release # for testing only
tags:
- 'v*' # When a tag starting with `v` is created e.g. v1.0.0

# Set Workflow-level environment variables
env:
Expand Down Expand Up @@ -53,21 +54,27 @@ jobs:
${{ vars.DOCKER_REGISTRY_URL }}/${{ vars.DOCKER_REPOSITORY }}/${{ env.PROJECT }}
ghcr.io/${{ github.repository }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# branch event
type=ref,event=branch
# dynamically set the branch name as a prefix (short sha format)
type=sha,prefix={{branch}}-
# tag event
type=ref,event=tag
type=ref,event=pr
type=sha
type=sha,format=long
# Docker Buildx Bake supports multi-platform builds: https://docs.docker.com/build/bake/
- name: Docker Build and Push (Bake)
env:
BUILD_IMAGE: registry.access.redhat.com/ubi8/openjdk-17
RUNTIME_IMAGE: registry.access.redhat.com/ubi8/openjdk-17-runtime
uses: docker/bake-action@v4 # https://github.com/marketplace/actions/docker-buildx-bake
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
set: |
build.args.BUILD_IMAGE=registry.access.redhat.com/ubi8/openjdk-17
build.args.RUNTIME_IMAGE=registry.access.redhat.com/ubi8/openjdk-17-runtime
build.args.BUILD_IMAGE=${{ env.BUILD_IMAGE }}
build.args.RUNTIME_IMAGE=${{ env.RUNTIME_IMAGE }}
targets: build
push: true
6 changes: 3 additions & 3 deletions container-structure-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ metadataTest:
exposedPorts: ["8080"]
volumes: []
entrypoint: []
cmd: ["/usr/bin/java", "-jar", "demoapp-backend.jar"]
workdir: "/home/jboss"
cmd: ["/usr/bin/java", "-jar", "/app/demoapp-backend.jar"]
workdir: /app
user: 185

commandTests:
Expand All @@ -48,7 +48,7 @@ fileExistenceTests:
path: /home/jboss/pom.xml
shouldExist: false
- name: Confirm existence of application JAR
path: /home/jboss/demoapp-backend.jar
path: /app/demoapp-backend.jar
shouldExist: true
permissions: -rw-r--r--
# UID and GID values are from based image: registry.access.redhat.com/ubi8/openjdk-17-runtime
Expand Down

0 comments on commit 2fa8176

Please sign in to comment.