Skip to content

feat: git hash with command #16

feat: git hash with command

feat: git hash with command #16

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build and push jms-be to docker hub
on:
push:
branches: [ "*" ]
permissions:
id-token: write
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout repository
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean install --file pom.xml
- name: Copy jar to dockerfiles
run: cp ./target/*.jar .github/dockerfiles/app.jar
- name: Get shortened git hash
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
echo "git_hash=$git_hash" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
file: Dockerfile_jms_be
tags: vladokat/jms-be:${{git rev-parse --short "$GITHUB_SHA"}}

Check failure on line 64 in .github/workflows/build-and-push-docker-hub.yaml

View workflow run for this annotation

GitHub Actions / Build and push jms-be to docker hub

Invalid workflow file

The workflow is not valid. .github/workflows/build-and-push-docker-hub.yaml (Line: 64, Col: 17): Unrecognized named-value: 'git'. Located at position 1 within expression: git rev-parse --short "$GITHUB_SHA"