|
| 1 | +on: push |
| 2 | + |
| 3 | +jobs: |
| 4 | + build: |
| 5 | + name: Build with rust |
| 6 | + strategy: |
| 7 | + fail-fast: false |
| 8 | + matrix: |
| 9 | + include: |
| 10 | + - architecture: x86_64-unknown-linux-musl |
| 11 | + platform: linux/amd64 |
| 12 | + artifact-name: amd64 |
| 13 | + - architecture: aarch64-unknown-linux-musl |
| 14 | + platform: linux/arm64/v8 |
| 15 | + artifact-name: arm64 |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v3 |
| 20 | + |
| 21 | + - name: Setup rust |
| 22 | + uses: dtolnay/rust-toolchain@stable |
| 23 | + with: |
| 24 | + toolchain: nightly |
| 25 | + |
| 26 | + - name: Handle Cache |
| 27 | + uses: swatinem/rust-cache@v2 |
| 28 | + with: |
| 29 | + key: ${{ matrix.architecture }} |
| 30 | + |
| 31 | + - name: Install cross |
| 32 | + uses: taiki-e/install-action@v2 |
| 33 | + with: |
| 34 | + tool: cross |
| 35 | + |
| 36 | + - name: Rust build |
| 37 | + run: | |
| 38 | + cross +nightly build --release -Z sparse-registry --target ${{ matrix.architecture }} |
| 39 | + cp target/${{ matrix.architecture }}/release/error_server . |
| 40 | +
|
| 41 | + - name: Upload |
| 42 | + uses: actions/upload-artifact@v3 |
| 43 | + with: |
| 44 | + name: ${{ matrix.artifact-name }} |
| 45 | + path: | |
| 46 | + error_server |
| 47 | + error.html |
| 48 | +
|
| 49 | +
|
| 50 | + push: |
| 51 | + name: Build and push Docker image |
| 52 | + needs: build |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + # we only need the Dockerfile and therefore we'll also only checkout that single file |
| 56 | + - name: Checkout |
| 57 | + uses: bhacaz/checkout-files@v2 |
| 58 | + with: |
| 59 | + files: Dockerfile |
| 60 | + branch: ${{ github.head_ref || github.ref_name }} |
| 61 | + |
| 62 | + - name: Set up Docker Buildx |
| 63 | + id: buildx |
| 64 | + uses: docker/setup-buildx-action@v2 |
| 65 | + |
| 66 | + - name: Login to Docker Hub |
| 67 | + uses: docker/login-action@v2 |
| 68 | + with: |
| 69 | + registry: ghcr.io |
| 70 | + username: ${{ github.actor }} |
| 71 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + |
| 73 | + - name: Docker metadata |
| 74 | + id: metadata |
| 75 | + uses: docker/metadata-action@v4 |
| 76 | + with: |
| 77 | + images: ghcr.io/${{ github.repository }} |
| 78 | + tags: | |
| 79 | + type=ref,event=branch |
| 80 | + type=ref,event=pr |
| 81 | + event=tag,type=semver,pattern={{version}} |
| 82 | + event=tag,type=semver,pattern={{major}}.{{minor}} |
| 83 | + event=tag,type=semver,pattern={{major}} |
| 84 | + type=sha |
| 85 | +
|
| 86 | + - name: Download AMD Build |
| 87 | + uses: actions/download-artifact@v3 |
| 88 | + with: |
| 89 | + name: amd64 |
| 90 | + path: linux/amd64 |
| 91 | + |
| 92 | + - name: Download ARM Build |
| 93 | + uses: actions/download-artifact@v3 |
| 94 | + with: |
| 95 | + name: arm64 |
| 96 | + path: linux/arm64 |
| 97 | + |
| 98 | + - name: Docker Build and push |
| 99 | + uses: docker/build-push-action@v3 |
| 100 | + with: |
| 101 | + push: true |
| 102 | + context: . |
| 103 | + platforms: linux/amd64,linux/arm64/v8 |
| 104 | + builder: ${{ steps.buildx.outputs.name }} |
| 105 | + tags: ${{ steps.metadata.outputs.tags }} |
| 106 | + labels: ${{ steps.metadata.outputs.labels }} |
0 commit comments