|
| 1 | +name: Build & publish nerc-bootstrap images |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [ published ] |
| 5 | + tags: [ 'v*.*.*' ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + paths: |
| 9 | + - ".github/workflows/build.yaml" |
| 10 | + - "containers/**" |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + IMAGE_NAME: ${{ github.repository }} |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-push-image: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - dockerfile: ./containers/base/Dockerfile |
| 24 | + image: ghcr.io/nerc-project/nerc-bootstrap/base |
| 25 | + - dockerfile: ./containers/dhcpd/Dockerfile |
| 26 | + image: ghcr.io/nerc-project/nerc-bootstrap/dhcpd |
| 27 | + - dockerfile: ./containers/tftpd/Dockerfile |
| 28 | + image: ghcr.io/nerc-project/nerc-bootstrap/tftpd |
| 29 | + - dockerfile: ./containers/httpd/Dockerfile |
| 30 | + image: ghcr.io/nerc-project/nerc-bootstrap/httpd |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + packages: write |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v2 |
| 38 | + |
| 39 | + - name: Log in to the Container registry |
| 40 | + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 |
| 41 | + with: |
| 42 | + registry: ${{ env.REGISTRY }} |
| 43 | + username: ${{ github.actor }} |
| 44 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + - name: Extract metadata (tags, labels) for Docker |
| 47 | + id: meta |
| 48 | + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 |
| 49 | + with: |
| 50 | + images: ${{ matrix.image }} |
| 51 | + |
| 52 | + - name: Build and push Docker image |
| 53 | + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc |
| 54 | + with: |
| 55 | + context: . |
| 56 | + file: ${{ matrix.dockerfile }} |
| 57 | + push: ${{ github.event_name != 'pull_request' }} |
| 58 | + tags: ${{ steps.meta.outputs.tags }} |
| 59 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments