|
| 1 | +--- |
| 2 | +name: Container Base Module |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - 'develop' |
| 8 | + - 'master' |
| 9 | + paths: |
| 10 | + - 'modules/container-base/**' |
| 11 | + - 'modules/dataverse-parent/pom.xml' |
| 12 | + - '.github/workflows/container_base_push.yml' |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - 'develop' |
| 16 | + - 'master' |
| 17 | + paths: |
| 18 | + - 'modules/container-base/**' |
| 19 | + - 'modules/dataverse-parent/pom.xml' |
| 20 | + - '.github/workflows/container_base_push.yml' |
| 21 | + |
| 22 | +env: |
| 23 | + IMAGE_TAG: unstable |
| 24 | + |
| 25 | +jobs: |
| 26 | + build: |
| 27 | + name: Build image |
| 28 | + runs-on: ubuntu-latest |
| 29 | + permissions: |
| 30 | + contents: read |
| 31 | + packages: read |
| 32 | + strategy: |
| 33 | + matrix: |
| 34 | + jdk: [ '11' ] |
| 35 | + # Only run in upstream repo - avoid unnecessary runs in forks |
| 36 | + if: ${{ github.repository_owner == 'IQSS' }} |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout repository |
| 40 | + uses: actions/checkout@v3 |
| 41 | + |
| 42 | + - name: Set up JDK ${{ matrix.jdk }} |
| 43 | + uses: actions/setup-java@v3 |
| 44 | + with: |
| 45 | + java-version: ${{ matrix.jdk }} |
| 46 | + distribution: 'adopt' |
| 47 | + - name: Cache Maven packages |
| 48 | + uses: actions/cache@v3 |
| 49 | + with: |
| 50 | + path: ~/.m2 |
| 51 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 52 | + restore-keys: ${{ runner.os }}-m2 |
| 53 | + |
| 54 | + - name: Build base container image with local architecture |
| 55 | + run: mvn -f modules/container-base -Pct package |
| 56 | + |
| 57 | + # Run anything below only if this is not a pull request. |
| 58 | + # Accessing, pushing tags etc. to DockerHub will only succeed in upstream because secrets. |
| 59 | + |
| 60 | + - if: ${{ github.event_name == 'push' && github.ref_name == 'develop' }} |
| 61 | + name: Push description to DockerHub |
| 62 | + uses: peter-evans/dockerhub-description@v3 |
| 63 | + with: |
| 64 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 65 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 66 | + repository: gdcc/base |
| 67 | + short-description: "Dataverse Base Container image providing Payara application server and optimized configuration" |
| 68 | + readme-filepath: ./modules/container-base/README.md |
| 69 | + |
| 70 | + - if: ${{ github.event_name != 'pull_request' }} |
| 71 | + name: Log in to the Container registry |
| 72 | + uses: docker/login-action@v2 |
| 73 | + with: |
| 74 | + registry: ${{ env.REGISTRY }} |
| 75 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 76 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 77 | + - if: ${{ github.event_name != 'pull_request' }} |
| 78 | + name: Set up QEMU for multi-arch builds |
| 79 | + uses: docker/setup-qemu-action@v2 |
| 80 | + - name: Re-set image tag based on branch |
| 81 | + if: ${{ github.ref_name == 'master' }} |
| 82 | + run: echo "IMAGE_TAG=stable" |
| 83 | + - if: ${{ github.event_name != 'pull_request' }} |
| 84 | + name: Deploy multi-arch base container image to Docker Hub |
| 85 | + run: mvn -f modules/container-base -Pct deploy -Dbase.image.tag=${{ env.IMAGE_TAG }} |
0 commit comments