|
| 1 | +name: Build and Publish PHP Extension |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['testing-actions'] |
| 6 | + |
| 7 | +jobs: |
| 8 | + |
| 9 | + start-runner: |
| 10 | + name: Start self-hosted EC2 runner |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + label: ${{ steps.start-ec2-runner.outputs.label }} |
| 14 | + ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} |
| 15 | + steps: |
| 16 | + - name: Configure AWS credentials |
| 17 | + uses: aws-actions/configure-aws-credentials@v2 |
| 18 | + with: |
| 19 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 20 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 21 | + aws-region: ${{ secrets.AWS_REGION }} |
| 22 | + |
| 23 | + - name: Start EC2 runner |
| 24 | + id: start-ec2-runner |
| 25 | + uses: machulav/ec2-github-runner@v2 |
| 26 | + with: |
| 27 | + mode: start |
| 28 | + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 29 | + ec2-image-id: ami-0e811aad4d084edb9 |
| 30 | + ec2-instance-type: t4g.2xlarge |
| 31 | + subnet-id: subnet-05010d45bfb86f5fb |
| 32 | + security-group-id: sg-01bd3845621443669 |
| 33 | + |
| 34 | + build_binaries: |
| 35 | + needs: start-runner |
| 36 | + strategy: |
| 37 | + matrix: |
| 38 | + os: |
| 39 | + - linux-x86_64 |
| 40 | + - macos-14 |
| 41 | + - ${{ needs.start-runner.outputs.label }} |
| 42 | + variant: |
| 43 | + - 'wasm-udf-dynamic' |
| 44 | + - 'wasm-udf-wasmedge' |
| 45 | + - 'wasm-udf' |
| 46 | + - '' |
| 47 | + |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + steps: |
| 50 | + #Debug output + special rustup config for the ubuntu/aarch64 runner |
| 51 | + - name: show step matrix details |
| 52 | + run: | |
| 53 | + env |
| 54 | + set -ex |
| 55 | + uname -a |
| 56 | + echo "os: ${{ matrix.os }}" |
| 57 | + echo "variant: ${{ matrix.variant }}" |
| 58 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > ./rustup.sh |
| 59 | + chmod a+x rustup.sh |
| 60 | + ./rustup.sh -y |
| 61 | + if [[ "${{ matrix.os}}" == "${{ needs.start-runner.outputs.label }}" ]]; then |
| 62 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable |
| 63 | + echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH |
| 64 | + echo "PATH=$PATH:/root/.cargo/bin" >> $GITHUB_PATH |
| 65 | + fi |
| 66 | + pwd |
| 67 | + whoami |
| 68 | +
|
| 69 | + stop-runner: |
| 70 | + name: Stop self-hosted EC2 runner |
| 71 | + needs: |
| 72 | + - start-runner # required to get output from the start-runner job |
| 73 | + - build_binaries # required to wait when the main job is done |
| 74 | + runs-on: ubuntu-latest |
| 75 | + if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs |
| 76 | + steps: |
| 77 | + - name: Configure AWS credentials |
| 78 | + uses: aws-actions/configure-aws-credentials@v1 |
| 79 | + with: |
| 80 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 81 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 82 | + aws-region: ${{ secrets.AWS_REGION }} |
| 83 | + - name: Stop EC2 runner |
| 84 | + uses: machulav/ec2-github-runner@v2 |
| 85 | + with: |
| 86 | + mode: stop |
| 87 | + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 88 | + label: ${{ needs.start-runner.outputs.label }} |
| 89 | + ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} |
0 commit comments