Skip to content

fix syntax

fix syntax #2

name: build gh release from tag
on:
push:
tags:
- "*/v*"
env:
REGISTRY: ghcr.io
jobs:
publish-ghcr-image:
runs-on: ubuntu-latest
steps:
- uses: olegtarasov/[email protected]
id: tagName
with:
tagRegex: (?<service>.*)\/v(?<version>.*) #example: backend/v1.2.3
tagRegexGroup: 0
- name: show-service
env:
ghRef: ${{ github.ref }}
service: ${{ steps.tagName.outputs.service }}
version: ${{ steps.tagName.outputs.version }}
tagFromAction: ${{ steps.tagName.outputs.tag }}
run: |
echo "Ref: $ghRef"
echo "Service: $service"
echo "Version: $version"
echo "tagFromAction: $tagFromAction"
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
env:
service: ${{ steps.tagName.outputs.service }}
with:
cache: 'maven'
cache-dependency-path: '${{ service }}/pom.xml'

Check failure on line 42 in .github/workflows/create-ghcr-image-from-tag.yml

View workflow run for this annotation

GitHub Actions / build gh release from tag

Invalid workflow file

The workflow is not valid. .github/workflows/create-ghcr-image-from-tag.yml (Line: 42, Col: 34): Unrecognized named-value: 'service'. Located at position 1 within expression: service .github/workflows/create-ghcr-image-from-tag.yml (Line: 61, Col: 18): Unrecognized named-value: 'service'. Located at position 1 within expression: service
java-version: '17'
distribution: 'temurin'
- name: build jar without tests
run: mvn -B -ntp -DskipTests package
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
env:
service: ${{ steps.tagName.outputs.service }}
image: ${{ env.REGISTRY }}/${{ github.repository }}-${{ service }}
tagDefinitionMajorOnly: "type=match,pattern=(${{ service }})/v(\\d).\\d.\\d,group=2"
tagDefinitionMajorMinor: "type=match,pattern=(${{ service }})/v(\\d.\\d).\\d,group=2"
tagDefinitionFullVersion: "type=match,pattern=(${{ service }})/v(.*),group=2"
with:
images: ${{ image }}
tags: |
${{ tagDefinitionMajorOnly }}
${{ tagDefinitionMajorMinor }}
${{ tagDefinitionFullVersion }}
type=raw,value=latest
- name: Build and push image
uses: docker/build-push-action@v5
env:
service: ${{ steps.tagName.outputs.service }}
with:
context: ./${{ service }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}