1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79name: cd
on:
push:
branches:
- main
paths-ignore:
- .github/CODEOWNERS
- "**/*.md"
defaults:
run:
shell: bash
env:
CARGO_INCREMENTAL: 1
RUSTFLAGS: -Dwarnings
permissions:
contents: read
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Setup
run: rustup install
- name: Build
run: |
cargo build --release --target x86_64-unknown-linux-musl
zip deploy.zip host.json hello/function.json target/x86_64-unknown-linux-musl/release/handler
- name: Upload deployment artifact
uses: actions/upload-artifact@v4
with:
name: deploy
path: deploy.zip
overwrite: true
deploy:
runs-on: ubuntu-latest
needs: build
environment: staging
steps:
- name: Download deployment artifact
uses: actions/download-artifact@v4
with:
name: deploy
- name: Log into staging environment
uses: azure/login@v2
with:
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
- name: Deploy to staging environment
run: |
az storage blob upload --blob-endpoint "$AZURE_STORAGE_URL" --container-name "$AZURE_STORAGE_CONTAINER" --auth-mode login --file deploy.zip --overwrite
env:
AZURE_STORAGE_CONTAINER: ${{ vars.AZURE_STORAGE_CONTAINER }}
AZURE_STORAGE_URL: ${{ vars.AZURE_STORAGE_URL }}
- name: Test staging environment
run: |
if [[ `curl --no-progress-meter --verbose "$AZURE_FUNCTIONAPP_URL/api/hello"` != 'Hello, world!' ]]; then
exit 1
fi
env:
AZURE_FUNCTIONAPP_URL: ${{ vars.AZURE_FUNCTIONAPP_URL }}