diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 55ca8cab54..b8248f9626 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: CI build +name: CI build and push on: push: @@ -7,33 +7,37 @@ on: branches: [ main ] jobs: - get-core-version: + get-pom-properties: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - id: query-pom - # Query POM for core version and save as output parameter + name: Get properties from POM + # Query POM for core and image version and save as output parameter run: | CORE_VERSION="$(mvn help:evaluate -Dexpression=io.cryostat.core.version -q -DforceStdout)" echo "::set-output name=core-version::v$CORE_VERSION" + IMAGE_VERSION="$(mvn help:evaluate -Dexpression=cryostat.imageVersion -q -DforceStdout)" + echo "::set-output name=image-version::$IMAGE_VERSION" outputs: core-version: ${{ steps.query-pom.outputs.core-version }} + image-version: ${{ steps.query-pom.outputs.image-version }} build-deps: runs-on: ubuntu-latest - needs: [get-core-version] + needs: [get-pom-properties] steps: - uses: actions/checkout@v2 with: repository: cryostatio/cryostat-core - ref: ${{ needs.get-core-version.outputs.core-version }} + ref: ${{ needs.get-pom-properties.outputs.core-version }} - uses: skjolber/maven-cache-github-action@v1 with: step: restore - run: mvn -B -U -DskipTests=true clean install - uses: actions/upload-artifact@v2 with: - name: container-jfr-core + name: cryostat-core path: /home/runner/.m2/repository/io/cryostat/cryostat-core/ - uses: skjolber/maven-cache-github-action@v1 with: @@ -41,7 +45,9 @@ jobs: build: runs-on: ubuntu-latest - needs: [build-deps] + needs: [get-pom-properties, build-deps] + env: + CRYOSTAT_IMG: quay.io/cryostat/cryostat steps: - uses: actions/checkout@v2 with: @@ -55,11 +61,34 @@ jobs: step: restore - uses: actions/download-artifact@v2 with: - name: container-jfr-core + name: cryostat-core path: /home/runner/.m2/repository/io/cryostat/cryostat-core/ - run: git submodule init - run: git submodule update - run: mvn -B -U clean verify + - name: Tag images + run: > + podman tag + ${{ env.CRYOSTAT_IMG }}:${{ needs.get-pom-properties.outputs.image-version }} + ${{ env.CRYOSTAT_IMG }}:${{ github.sha }} + ${{ env.CRYOSTAT_IMG }}:latest + if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }} - uses: skjolber/maven-cache-github-action@v1 with: step: save + - name: Push to quay.io + id: push-to-quay + uses: redhat-actions/push-to-registry@v2 + with: + image: cryostat + tags: > + ${{ needs.get-pom-properties.outputs.image-version }} + ${{ github.sha }} + latest + registry: quay.io/cryostat + username: cryostat+bot + password: ${{ secrets.REGISTRY_PASSWORD }} + if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }} + - name: Print image URL + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" + if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }}