|
| 1 | +name: NGINX v1.25 Image |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - "*" |
| 7 | + paths: |
| 8 | + - 'images/nginx-1.25/**' |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + paths: |
| 13 | + - 'images/nginx-1.25/**' |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + changes: |
| 20 | + permissions: |
| 21 | + contents: read # for dorny/paths-filter to fetch a list of changed files |
| 22 | + pull-requests: read # for dorny/paths-filter to read pull requests |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + nginx: ${{ steps.filter.outputs.nginx }} |
| 26 | + tag: ${{ steps.filter.outputs.tag }} |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 30 | + - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 |
| 31 | + id: filter |
| 32 | + with: |
| 33 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + filters: | |
| 35 | + nginx: |
| 36 | + - 'images/nginx-1.25/**' |
| 37 | + tag: |
| 38 | + - 'images/nginx-1.25/TAG' |
| 39 | +
|
| 40 | + build: |
| 41 | + permissions: |
| 42 | + contents: read # for dorny/paths-filter to fetch a list of changed files |
| 43 | + pull-requests: read # for dorny/paths-filter to read pull requests |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: changes |
| 46 | + if: | |
| 47 | + (github.event_name != 'push' && github.ref != 'refs/heads/main' && needs.changes.outputs.nginx == 'true') |
| 48 | + env: |
| 49 | + PLATFORMS: linux/amd64 |
| 50 | + steps: |
| 51 | + - name: Checkout |
| 52 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 53 | + - name: Set up Go |
| 54 | + id: go |
| 55 | + uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 |
| 56 | + with: |
| 57 | + go-version: '1.21.5' |
| 58 | + check-latest: true |
| 59 | + - name: Set up QEMU |
| 60 | + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 |
| 61 | + - name: Set up Docker Buildx |
| 62 | + id: buildx |
| 63 | + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 |
| 64 | + with: |
| 65 | + version: latest |
| 66 | + platforms: ${{ env.PLATFORMS }} |
| 67 | + - name: Prepare Host |
| 68 | + run: | |
| 69 | + curl -LO https://dl.k8s.io/release/v1.27.3/bin/linux/amd64/kubectl |
| 70 | + chmod +x ./kubectl |
| 71 | + sudo mv ./kubectl /usr/local/bin/kubectl |
| 72 | + - name: build-image |
| 73 | + run: | |
| 74 | + cd images/nginx-1.25/rootfs && docker buildx build --platform=${{ env.PLATFORMS }} --load -t nginx-1.25:1.0.0-dev . |
| 75 | + - name: load-image |
| 76 | + run: | |
| 77 | + make clean-image build |
| 78 | + make -C test/e2e-image image |
| 79 | + docker build \ |
| 80 | + --platform linux \ |
| 81 | + --no-cache \ |
| 82 | + --build-arg BASE_IMAGE="nginx-1.25:1.0.0-dev" \ |
| 83 | + --build-arg VERSION="0.0.1-${{ github.sha }}" \ |
| 84 | + --build-arg TARGETARCH="amd64" \ |
| 85 | + --build-arg COMMIT_SHA="git-${{ github.sha }}" \ |
| 86 | + --build-arg BUILD_ID=""UNSET"" \ |
| 87 | + -t ingress-controller/controller:1.0.0-dev rootfs |
| 88 | + docker save \ |
| 89 | + nginx-ingress-controller:e2e \ |
| 90 | + ingress-controller/controller:1.0.0-dev \ |
| 91 | + nginx-1.25:1.0.0-dev \ |
| 92 | + | gzip > docker.tar.gz |
| 93 | + - name: cache |
| 94 | + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 |
| 95 | + with: |
| 96 | + name: docker.tar.gz |
| 97 | + path: docker.tar.gz |
| 98 | + retention-days: 2 |
| 99 | + |
| 100 | + e2e-test: |
| 101 | + name: Kubernetes |
| 102 | + runs-on: ubuntu-latest |
| 103 | + needs: |
| 104 | + - build |
| 105 | + strategy: |
| 106 | + matrix: |
| 107 | + k8s: [v1.27.3, v1.28.0, v1.29.0] |
| 108 | + steps: |
| 109 | + - name: Checkout |
| 110 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 111 | + |
| 112 | + - name: cache |
| 113 | + uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 |
| 114 | + with: |
| 115 | + name: docker.tar.gz |
| 116 | + |
| 117 | + - name: Create Kubernetes ${{ matrix.k8s }} cluster |
| 118 | + id: kind |
| 119 | + run: | |
| 120 | + kind create cluster --image=kindest/node:${{ matrix.k8s }} --config test/e2e/kind.yaml |
| 121 | + |
| 122 | + - name: Load images from cache |
| 123 | + run: | |
| 124 | + echo "loading docker images..." |
| 125 | + gzip -dc docker.tar.gz | docker load |
| 126 | + |
| 127 | + - name: Run e2e tests |
| 128 | + env: |
| 129 | + KIND_CLUSTER_NAME: kind |
| 130 | + SKIP_CLUSTER_CREATION: true |
| 131 | + SKIP_IMAGE_CREATION: true |
| 132 | + SKIP_OPENTELEMETRY_TESTS: true |
| 133 | + run: | |
| 134 | + kind get kubeconfig > $HOME/.kube/kind-config-kind |
| 135 | + make NGINX_BASE_IMAGE="nginx-1.25:1.0.0-dev" kind-e2e-test |
| 136 | + |
| 137 | + push: |
| 138 | + permissions: |
| 139 | + contents: write |
| 140 | + packages: write |
| 141 | + runs-on: ubuntu-latest |
| 142 | + needs: changes |
| 143 | + if: | |
| 144 | + (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changes.outputs.tag == 'true') |
| 145 | + env: |
| 146 | + PLATFORMS: linux/amd64,linux/arm,linux/arm64,linux/s390x |
| 147 | + steps: |
| 148 | + - name: Checkout |
| 149 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 150 | + - name: Set up QEMU |
| 151 | + uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 |
| 152 | + - name: Set up Docker Buildx |
| 153 | + id: buildx |
| 154 | + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 |
| 155 | + with: |
| 156 | + version: latest |
| 157 | + platforms: ${{ env.PLATFORMS }} |
| 158 | + - name: Login to GitHub Container Registry |
| 159 | + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 |
| 160 | + with: |
| 161 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 162 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 163 | + - name: build-image |
| 164 | + run: | |
| 165 | + export TAG=$(cat images/nginx-1.25/TAG) |
| 166 | + cd images/nginx-1.25/rootfs && docker buildx build --platform=${{ env.PLATFORMS }} --push --load -t ingressnginx/nginx-1.25:${TAG} . |
| 167 | +
|
0 commit comments