-
-
Notifications
You must be signed in to change notification settings - Fork 18
87 lines (69 loc) · 2.75 KB
/
deploy.yml
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
79
80
81
82
83
84
85
86
87
name: Deploy
on:
push:
branches: [master]
workflow_dispatch:
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
REGISTRY_NAME: swiftfiddle.azurecr.io
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
CLUSTER_NAME: swiftfiddle
RESOURCE_GROUP: swiftfiddle
SERVICE_NAME: web-frontend
FONTAWESOME_TOKEN: ${{ secrets.FONTAWESOME_TOKEN }}
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- name: Update Package.swift.json
run: |
set -ex
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git pull --rebase origin master
tempdir=$(mktemp -d)
filename="Package.swift"
curl -sfL -o "$tempdir/$filename" https://raw.github.com/swiftfiddle/swiftfiddle-lsp/main/Resources/ProjectTemplate/$filename
sed -i 's/swift-tools-version:5.5/swift-tools-version:5.4/g' "$tempdir/Package.swift"
swift package --package-path "$tempdir" dump-package > Resources/$filename.json
git add Resources/$filename.json
git diff-index --quiet HEAD || git commit -m "Update $filename.json"
git push origin master
- uses: azure/login@v1
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- uses: azure/docker-login@v1
with:
login-server: ${{ env.REGISTRY_NAME }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Build and Push Docker Images
run: |
set -ex
IMAGE_TAG=${{ env.REGISTRY_NAME }}/${{ env.RESOURCE_GROUP }}/${{ env.SERVICE_NAME }}:latest
docker build --build-arg FONTAWESOME_TOKEN=${{ env.FONTAWESOME_TOKEN }} --rm --tag ${IMAGE_TAG} .
docker push ${IMAGE_TAG}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: azure/setup-kubectl@v3
- uses: azure/login@v1
with:
creds: ${{ env.AZURE_CREDENTIALS }}
- uses: azure/aks-set-context@v3
with:
resource-group: ${{ env.RESOURCE_GROUP }}
cluster-name: ${{ env.CLUSTER_NAME }}
- name: Deploy
run: |
set -ex
sed "s/%COMMIT_SHA%/${{ github.sha }}/g;" "k8s/pod_template.yaml" | kubectl apply -f -
kubectl rollout status deployment/${{ env.SERVICE_NAME }}
kubectl get services -o wide