Skip to content

publish automatically on main and manually on other branches #2

publish automatically on main and manually on other branches

publish automatically on main and manually on other branches #2

Workflow file for this run

name: build and publish on demand
on:
workflow_dispatch:
push:
branches: [ "**" ]
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_REGISTRY: ghcr.io/${{ github.repository }}
DOCKER_TAG_SHA: ${{ github.sha }}
DOCKER_TAG_REF: ${{ replace(github.ref_name, '/', '_') }}

Check failure on line 12 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / build and publish on demand

Invalid workflow file

The workflow is not valid. .github/workflows/publish.yml (Line: 12, Col: 19): Unrecognized function: 'replace'. Located at position 1 within expression: replace(github.ref_name, '/', '_')
DOCKER_REGISTRY_USERNAME: ${{ github.actor }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
jobs:
build-and-publish-image:
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Log into registry ${{ env.DOCKER_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image except for main branch
if: github.ref != 'refs/heads/main'
run: |
./mvnw install \
-B --no-transfer-progress --file pom.xml \
-D docker.app.image.registry=${{ env.DOCKER_IMAGE_REGISTRY }} \
-P exec.docker.image \
-D docker.app.image.tag.ref=${{ env.DOCKER_TAG_REF }} \
-D docker.app.image.tag.sha=${{ env.DOCKER_TAG_SHA }} \
-am -pl addondemo.app.image
- name: Build and push image for main branch
if: github.ref == 'refs/heads/main'
run: |
./mvnw install \
-B --no-transfer-progress --file pom.xml \
-D docker.app.image.registry=${{ env.DOCKER_IMAGE_REGISTRY }} \
-P exec.docker.image \
-D docker.app.image.tag.sha=${{ env.DOCKER_TAG_SHA }} \
-am -pl addondemo.app.image