|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +env: |
| 8 | + BUILDX_CACHE: /tmp/.buildx-tag-cache |
| 9 | + CACHE_KEY: docker-erddap-buildx-tag- |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build and test Docker Image |
| 14 | + runs-on: ubuntu-20.04 |
| 15 | + timeout-minutes: 10 |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v1 |
| 20 | + |
| 21 | + - name: Set up Docker Buildx |
| 22 | + uses: docker/setup-buildx-action@v1 |
| 23 | + |
| 24 | + - name: Cache Docker layers |
| 25 | + uses: actions/cache@v2 |
| 26 | + with: |
| 27 | + path: ${ BUILDX_CACHE } |
| 28 | + key: ${ CACHE_KEY }${{ github.sha }} |
| 29 | + restore-keys: | |
| 30 | + ${ CACHE_KEY } |
| 31 | +
|
| 32 | + - name: Login to Docker Hub |
| 33 | + uses: docker/login-action@v1 |
| 34 | + continue-on-error: true |
| 35 | + with: |
| 36 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 37 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 38 | + |
| 39 | + - name: Build release |
| 40 | + if: github.event_name == 'release' && github.event.action == 'created' |
| 41 | + uses: docker/build-push-action@v2 |
| 42 | + with: |
| 43 | + push: false |
| 44 | + tags: axiom/docker-erddap:${{ github.event.release.tag_name }} |
| 45 | + cache-from: type=local,src=${ BUILDX_CACHE } |
| 46 | + cache-to: type=local,dest=${ BUILDX_CACHE } |
| 47 | + outputs: type=docker |
| 48 | + |
| 49 | + - name: Run Docker Image in Background |
| 50 | + run: docker run -d -p 8080:8080 axiom/docker-erddap:${{ github.event.release.tag_name }} |
| 51 | + |
| 52 | + - name: Check that ERDDAP Docker Image will return a 200 |
| 53 | + uses: ifaxity/wait-on-action@v1 |
| 54 | + timeout-minutes: 1 |
| 55 | + with: |
| 56 | + resource: http://localhost:8080/erddap/index.html |
| 57 | + |
| 58 | + push: |
| 59 | + name: Push tagged image to Docker Hub |
| 60 | + runs-on: ubuntu-20.04 |
| 61 | + timeout-minutes: 10 |
| 62 | + needs: build |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v1 |
| 67 | + |
| 68 | + - name: Set up Docker Buildx |
| 69 | + uses: docker/setup-buildx-action@v1 |
| 70 | + |
| 71 | + - name: Cache Docker layers |
| 72 | + uses: actions/cache@v2 |
| 73 | + with: |
| 74 | + path: ${ BUILDX_CACHE } |
| 75 | + key: ${ CACHE_KEY }${{ github.sha }} |
| 76 | + restore-keys: | |
| 77 | + ${ CACHE_KEY } |
| 78 | +
|
| 79 | + - name: Login to Docker Hub |
| 80 | + uses: docker/login-action@v1 |
| 81 | + with: |
| 82 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 83 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 84 | + |
| 85 | + - name: Push tagged image to Docker Hub |
| 86 | + uses: docker/build-push-action@v2 |
| 87 | + with: |
| 88 | + push: true |
| 89 | + tags: ${{ github.event.release.tag_name }} |
| 90 | + cache-from: type=local,src=${ BUILDX_CACHE } |
| 91 | + cache-to: type=local,dest=${ BUILDX_CACHE } |
0 commit comments