|
| 1 | +name: copilot-build-images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + REACT_APP_BACKEND_URI: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + REACT_APP_AAD_AUTHORITY: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + REACT_APP_AAD_CLIENT_ID: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + REACT_APP_AAD_API_SCOPE: |
| 16 | + required: false |
| 17 | + type: string |
| 18 | +env: |
| 19 | + REGISTRY: ghcr.io |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-and-push-image: |
| 23 | + name: Build and push images |
| 24 | + runs-on: ubuntu-latest |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + include: |
| 29 | + - file: ./docker/webapi/Dockerfile |
| 30 | + image: ${{ github.repository }}-webapi |
| 31 | + build-args: | |
| 32 | +
|
| 33 | + - file: ./docker/webapp/Dockerfile |
| 34 | + image: ${{ github.repository }}-webapp |
| 35 | + build-args: | |
| 36 | +
|
| 37 | + - file: ./docker/webapp/Dockerfile.nginx |
| 38 | + image: ${{ github.repository }}-webapp-nginx |
| 39 | + build-args: | |
| 40 | + REACT_APP_BACKEND_URI=${{ inputs.REACT_APP_BACKEND_URI }} |
| 41 | + REACT_APP_AAD_AUTHORITY=${{ inputs.REACT_APP_AAD_AUTHORITY }} |
| 42 | + REACT_APP_AAD_CLIENT_ID=${{ inputs.REACT_APP_AAD_CLIENT_ID }} |
| 43 | + REACT_APP_AAD_API_SCOPE=${{ inputs.REACT_APP_AAD_API_SCOPE }} |
| 44 | + permissions: |
| 45 | + contents: read |
| 46 | + packages: write |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Checkout repository |
| 50 | + uses: actions/checkout@v3 |
| 51 | + |
| 52 | + - name: Login container registry |
| 53 | + uses: docker/login-action@v2 |
| 54 | + with: |
| 55 | + registry: ${{ env.REGISTRY }} |
| 56 | + username: ${{ github.actor }} |
| 57 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + |
| 59 | + - name: Extract metadata (tags, labels) |
| 60 | + id: meta |
| 61 | + uses: docker/metadata-action@v4 |
| 62 | + with: |
| 63 | + images: ${{ env.REGISTRY }}/${{ matrix.image }} |
| 64 | + tags: | |
| 65 | + type=ref,event=branch |
| 66 | + type=ref,event=pr |
| 67 | + type=semver,pattern={{version}} |
| 68 | + type=semver,pattern={{major}} |
| 69 | + type=semver,pattern={{major}}.{{minor}} |
| 70 | +
|
| 71 | + - name: Build and push image |
| 72 | + uses: docker/build-push-action@v3 |
| 73 | + with: |
| 74 | + context: . |
| 75 | + file: ${{ matrix.file }} |
| 76 | + push: true |
| 77 | + tags: ${{ steps.meta.outputs.tags }} |
| 78 | + labels: ${{ steps.meta.outputs.labels }} |
| 79 | + build-args: ${{ matrix.build-args }} |
0 commit comments