Update main.rs #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Test, build, and deploy" | |
on: | |
push: | |
branches: [main] | |
# https://docs.fastly.com/en/ngwaf/installing-the-agent-on-ubuntu#install-and-configure-the-signal-sciences-agent-package | |
# sudo service sigsci-agent start | |
jobs: | |
run-waf-tests: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Fastly CLI | |
uses: fastly/compute-actions/setup@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Compute@Edge Package | |
uses: fastly/compute-actions/build@v6 | |
- name: Run local Compute # skips the build process | |
run: | | |
fastly compute serve --skip-build & | |
sleep 5 | |
curl -si -X GET "http://0.0.0.0:7676/anything/from-gh-action-c-and-e" | |
- name: install ngwaf | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y apt-transport-https wget gnupg | |
wget -qO - https://apt.signalsciences.net/release/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/sigsci.gpg | |
sudo echo "deb [signed-by=/usr/share/keyrings/sigsci.gpg] https://apt.signalsciences.net/release/ubuntu/ jammy main" | sudo tee /etc/apt/sources.list.d/sigsci-release.list | |
sudo apt-get update | |
sudo apt-get install sigsci-agent | |
- name: start ngwaf | |
env: | |
SIGSCI_ACCESSKEYID: ${{ secrets.ACCESSKEYID }} | |
SIGSCI_SECRETACCESSKEY: ${{ secrets.SECRETACCESSKEY }} | |
SIGSCI_REVPROXY_LISTENER: "app1:{listener=http://0.0.0.0:8888,upstreams=http://0.0.0.0:7676/,pass-host-header=false}" | |
SIGSCI_UPLOAD_INTERVAL: "10s" | |
# "app1:{listener=http://0.0.0.0:8888,upstreams=https://http-me.edgecompute.app:443/,pass-host-header=false}" | |
run: | | |
/usr/sbin/sigsci-agent & | |
ps | |
- name: anything endpoint request through ngwaf and compute | |
# curl -X GET "https://http-me.edgecompute.app/" | |
run: | | |
curl -si -X GET "http://0.0.0.0:8888/anything/from-gh-action-ngwaf-and-compute?ghaction=../../../etc/passwd" | |
- name: Give time for log to upload | |
run: | | |
sleep 120 | |
deploy: | |
needs: run-waf-tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: 1.54.0 # current Rust toolchain for Compute@Edge | |
target: wasm32-wasi # WebAssembly target | |
- name: Deploy to Compute@Edge | |
uses: fastly/compute-actions@v5 | |
env: | |
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }} | |
with: | |
service_id: ${{ secrets.FASTLY_SERVICE_ID }} # optional, defaults to value in fastly.toml | |
comment: 'Deployed via GitHub Actions' # optional | |
- name: Update KV Store | |
env: | |
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }} | |
FASTLY_KV_STORE: ${{ secrets.FASTLY_KV_STORE }} | |
run: | | |
fastly kv-store-entry create --dir ./static-assets/ --store-id=$FASTLY_KV_STORE |