|
| 1 | +name: Add Tags to Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-if-needed: |
| 9 | + if: github.repository == 'rht-labs/lodestar-artifacts' |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Check whether we need to build this or not |
| 13 | + id: need_to_build |
| 14 | + run: | |
| 15 | + function image_exists() { |
| 16 | + curl --silent -f -lSL https://quay.io/v1/repositories/rht-labs/lodestar-artifacts/tags/$1 > /dev/null |
| 17 | + } |
| 18 | + if image_exists ${{ github.sha }}; then |
| 19 | + echo "Image exists - not building" |
| 20 | + echo ::set-output name=need_to_build::0 |
| 21 | + else |
| 22 | + echo "Image needs to be built" |
| 23 | + echo ::set-output name=need_to_build::1 |
| 24 | + fi |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + if: steps.need_to_build.outputs.need_to_build == 1 |
| 27 | + - uses: redhat-cop/github-actions/s2i@v2 |
| 28 | + if: steps.need_to_build.outputs.need_to_build == 1 |
| 29 | + with: |
| 30 | + base: registry.access.redhat.com/ubi8/openjdk-11:1.3 |
| 31 | + output_image: "quay.io/rht-labs/lodestar-artifacts:${{ github.sha }}" |
| 32 | + image_push_registry: quay.io |
| 33 | + image_push_username: ${{ secrets.QUAY_USERNAME }} |
| 34 | + image_push_password: ${{ secrets.QUAY_PASSWORD }} |
| 35 | + |
| 36 | + release: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + needs: build-if-needed |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + - name: tag with release version |
| 42 | + |
| 43 | + with: |
| 44 | + image_name: rht-labs/lodestar-artifacts |
| 45 | + image_old_tag: ${{ github.sha }} |
| 46 | + image_new_tag: ${{ github.event.release.tag_name }} |
| 47 | + registry: quay.io |
| 48 | + registry_username: ${{ secrets.QUAY_USERNAME }} |
| 49 | + registry_password: ${{ secrets.QUAY_PASSWORD }} |
| 50 | + - name: tag with latest |
| 51 | + |
| 52 | + with: |
| 53 | + image_name: rht-labs/lodestar-artifacts |
| 54 | + image_old_tag: ${{ github.sha }} |
| 55 | + registry: quay.io |
| 56 | + registry_username: ${{ secrets.QUAY_USERNAME }} |
| 57 | + registry_password: ${{ secrets.QUAY_PASSWORD }} |
0 commit comments