|
1 | 1 | name: Build |
2 | 2 |
|
3 | | -on: |
4 | | - pull_request: |
5 | | - branches: |
6 | | - - '*' |
7 | | - push: |
8 | | - branches: |
9 | | - - '*' |
10 | | - release: |
11 | | - types: |
12 | | - - published |
| 3 | +on: [push, pull_request, workflow_dispatch] |
| 4 | + |
13 | 5 | jobs: |
14 | | - docker: |
15 | | - name: Docker |
16 | 6 |
|
| 7 | + config: |
17 | 8 | runs-on: ubuntu-latest |
18 | | - strategy: |
19 | | - fail-fast: true |
20 | | - timeout-minutes: 240 |
21 | | - |
| 9 | + outputs: |
| 10 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
22 | 11 | steps: |
23 | | - - uses: actions/checkout@v2 |
24 | | - - name: Build and push Docker images |
25 | | - uses: docker/build-push-action@v1 |
26 | | - with: |
27 | | - username: ${{ secrets.DOCKER_USERNAME }} |
28 | | - password: ${{ secrets.DOCKER_PASSWORD }} |
29 | | - repository: pdal/lambda |
30 | | - tag_with_ref: true |
31 | | - tag_with_sha: true |
32 | | - push: ${{ startsWith(github.ref, 'refs/tags/') }} |
33 | | - |
34 | | - # if: ${{ startsWith(github.ref, 'refs/tags/') }} |
35 | | - |
| 12 | + - id: set-matrix |
| 13 | + run: echo "::set-output name=matrix::{\"include\":[{\"type\":\"amd64\",\"image\":\"amazon/aws-lambda-provided:al2\", \"arch\":\"x86_64\"},{\"type\":\"arm64\",\"image\":\"amazon/aws-lambda-provided:al2.2022.03.02.08\", \"arch\":\"arm64\"}] }" |
36 | 14 |
|
37 | | - layer: |
38 | | - name: Layer |
39 | | - needs: [docker] |
40 | | - container: pdal/lambda |
41 | 15 |
|
| 16 | + containers: |
| 17 | + needs: config |
42 | 18 | runs-on: ubuntu-latest |
43 | 19 | strategy: |
44 | 20 | fail-fast: true |
45 | | - timeout-minutes: 60 |
46 | | - |
| 21 | + matrix: ${{fromJson(needs.config.outputs.matrix)}} |
| 22 | + env: |
| 23 | + PUSH_PACKAGES: ${{ github.repository_owner == 'PDAL' && github.event_name != 'pull_request'}} |
47 | 24 | steps: |
48 | 25 | - uses: actions/checkout@v2 |
49 | | - - name: Package |
50 | | - shell: bash -l {0} |
| 26 | + - name: Set up QEMU |
| 27 | + uses: docker/setup-qemu-action@v2 |
| 28 | + |
| 29 | + - name: Lint |
| 30 | + id: lint |
51 | 31 | run: | |
52 | | - /package-pdal.sh |
| 32 | + echo "are we pushing packages" ${{ env.PUSH_PACKAGES }} |
| 33 | + echo "event_name" ${{ github.event_name }} |
| 34 | + echo "ref" ${{ github.ref }} |
| 35 | + - name: Setup Docker Buildx |
| 36 | + id: buildx |
| 37 | + uses: docker/setup-buildx-action@v1 |
| 38 | + with: |
| 39 | + version: latest |
| 40 | + - if: ${{ env.PUSH_PACKAGES == 'true' }} |
| 41 | + name: Login to GitHub Container Registry |
| 42 | + uses: docker/login-action@v1 |
| 43 | + with: |
| 44 | + registry: ghcr.io |
| 45 | + username: ${{ github.repository_owner }} |
| 46 | + password: ${{ secrets.GHCR_TOKEN }} |
| 47 | + - name: Prepare |
| 48 | + id: prep |
| 49 | + run: | |
| 50 | + VERSION=sha-${GITHUB_SHA::8} |
| 51 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 52 | + VERSION=${GITHUB_REF/refs\/tags\//} |
| 53 | + fi |
| 54 | + echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 55 | + echo ::set-output name=VERSION::${VERSION} |
| 56 | + - name: Build image |
| 57 | + uses: docker/build-push-action@v2 |
| 58 | + with: |
| 59 | + push: ${{ env.PUSH_PACKAGES == 'true' }} |
| 60 | + builder: ${{ steps.buildx.outputs.name }} |
| 61 | + context: . |
| 62 | + file: ./Dockerfile |
| 63 | + platforms: linux/${{ matrix.type}} |
| 64 | + build-args: | |
| 65 | + LAMBDA_IMAGE=${{ matrix.image }} |
| 66 | + RIE_ARCH=${{ matrix.arch }} |
| 67 | + tags: | |
| 68 | + ghcr.io/pdal/lambda:${{ steps.prep.outputs.VERSION }} |
| 69 | + ghcr.io/pdal/lambda:latest |
| 70 | + labels: | |
| 71 | + org.opencontainers.image.title=${{ github.event.repository.name }} |
| 72 | + org.opencontainers.image.description=${{ github.event.repository.description }} |
| 73 | + org.opencontainers.image.source=${{ github.event.repository.html_url }} |
| 74 | + org.opencontainers.image.url=${{ github.event.repository.html_url }} |
| 75 | + org.opencontainers.image.revision=${{ github.sha }} |
| 76 | + org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }} |
| 77 | + org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }} |
| 78 | +
|
0 commit comments