Skip to content

Fix for deprecated of set-output in GH actions (#183) #27

Fix for deprecated of set-output in GH actions (#183)

Fix for deprecated of set-output in GH actions (#183) #27

Workflow file for this run

name: Docker image
on:
push:
branches: [ master ]
release:
types: [ prereleased, released ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Run Java tests
run: mvn test
- name: Persist Java tests reports
if: always()
uses: actions/upload-artifact@v2
with:
name: Test reports
path: |
gtfs-realtime-validator-lib/target/surefire-reports
gtfs-realtime-validator-webapp/target/surefire-reports
build_push:
needs: test
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/mobilitydata/gtfs-realtime-validator
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="${DOCKER_IMAGE}:latest"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Package lib and webapp JARs with Maven
run: mvn package
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=https://github.com/mobilitydata/gtfs-realtime-validator.git
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
# should be org.opencontainers.image.source=${{ github.event.repository.clone_url }} but caps in MobilityData seem to break something