Update Dockerfile #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Continuous Integration | |
on: | |
push: | |
branches: [ master ] | |
paths-ignore: | |
- 'README.md' | |
- '.github/**' | |
workflow_call: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Java Build & Push | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
version: ${{ steps.getVersion.outputs.version }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
cache: maven | |
- name: pull | |
run: | | |
git fetch && git reset --hard origin/master | |
- name: Get Project Version from pom.xml | |
uses: entimaniac/[email protected] | |
id: getVersion | |
- name: Print the version | |
run: echo "The version we just got is ${{ steps.getVersion.outputs.version }}" | |
- name: Build with Maven | |
run: | | |
mvn --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean install --file pom.xml | |
- name: Push file to core VM | |
env: | |
source-jar: 'target/cerberus-robot-extension*full.jar' | |
destination: '[email protected]:/opt/delivery/' | |
run: | | |
echo "${{secrets.DEPLOY_KEY}}" > deploy_key | |
chmod 600 ./deploy_key | |
sudo rsync -chav \ | |
-e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' ${{env.source-jar}} ${{env.destination}} | |
- name: Push file to Github Release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "github-actions" | |
git tag -f -a ${{ steps.getVersion.outputs.version }} -m "Release ${{ steps.getVersion.outputs.version }}." | |
git push -f origin ${{ steps.getVersion.outputs.version }} | |
gh release list | |
gh release upload ${{ steps.getVersion.outputs.version }} ./target/cerberus-robot-extension-${{ steps.getVersion.outputs.version }}-full.jar --clobber | |
docker: | |
name: Docker Build & Push | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
attestations: write | |
id-token: write | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: cerberustesting/cerberus-robot-extension | |
- name: Build and push Docker image | |
id: push | |
env: | |
version: ${{needs.build.outputs.version}} | |
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | |
with: | |
context: . | |
file: ./docker/Dockerfile | |
push: true | |
build-args: | | |
VERSION=${{env.version}} | |
tags: cerberustesting/cerberus-robot-extension:${{env.version}} | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: index.docker.io/cerberustesting/cerberus-robot-extension | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: false |