Skip to content

Commit c378825

Browse files
fix(fly-deploy.yml): cache deployment, deploy with build secret
1 parent 6b55e1f commit c378825

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

.github/workflows/fly-deploy.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1-
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
2-
31
name: Fly Deploy
2+
43
on:
54
push:
65
branches:
76
- main
7+
88
jobs:
99
deploy:
1010
name: Deploy app
11-
runs-on: ubuntu-latest
12-
concurrency: deploy-group # optional: ensure only one action runs at a time
11+
runs-on: blacksmith-4vcpu-ubuntu-2404
12+
concurrency: deploy-group
1313
steps:
14-
- uses: actions/checkout@v4
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
17+
- uses: SwiftyLab/setup-swift@latest
18+
with:
19+
swift-version: "6.1"
20+
21+
- name: Get Cache
22+
uses: useblacksmith/cache@v5
23+
id: autoscaler-build
24+
with:
25+
key: deploy-cache-${{ hashFiles('SeleniumGridNodeMachineAutoscaler/Package.resolved') }}
26+
path: SeleniumGridNodeMachineAutoscaler/.build
27+
1528
- uses: superfly/flyctl-actions/setup-flyctl@master
16-
- run: flyctl deploy --remote-only
29+
- name: Deploy App
30+
run: |
31+
echo "GH_SSH_AUTHENTICATION_TOKEN: ${{ secrets.GH_SSH_AUTHENTICATION_TOKEN }}"
32+
cd ./SeleniumGridNodeMachineAutoscaler && npm run deploy -- ./SeleniumGridNodeMachineAutoscaler/ --config=./infra/autoscaler.toml --build-secret GITHUB_SSH_AUTHENTICATION_TOKEN=${{ secrets.GH_SSH_AUTHENTICATION_TOKEN }}
1733
env:
1834
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

SeleniumGridNodeMachineAutoscaler/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ db.sqlite
99
.env
1010
.env.*
1111
!.env.example
12-
.build-secrets
1312
infra/GITHUB_SSH_AUTHENTICATION_TOKEN

SeleniumGridNodeMachineAutoscaler/Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
1212
# Set up a build area
1313
WORKDIR /build
1414

15+
RUN --mount=type=secret,id=GITHUB_SSH_AUTHENTICATION_TOKEN \
16+
TOKEN=$(cat /run/secrets/GITHUB_SSH_AUTHENTICATION_TOKEN) && \
17+
git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/"
18+
1519
# First just resolve dependencies.
1620
# This creates a cached layer that can be reused
1721
# as long as your Package.swift/Package.resolved
@@ -20,12 +24,6 @@ COPY ./Package.* ./
2024
RUN swift package resolve \
2125
$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)
2226

23-
RUN --mount=type=secret,id=GITHUB_SSH_AUTHENTICATION_TOKEN \
24-
echo "machine github.com login x password $(head -n 1 /run/secrets/GITHUB_SSH_AUTHENTICATION_TOKEN)" && \
25-
git config \
26-
--global \
27-
url."https://${GITHUB_ID}:${GITHUB_SSH_AUTHENTICATION_TOKEN}@github.com/".insteadOf \
28-
"https://github.com/"
2927

3028
# Copy entire repo into container
3129
COPY . .

SeleniumGridNodeMachineAutoscaler/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let package = Package(
1111
.package(url: "https://github.com/vapor/vapor.git", from: "4.115.0"),
1212
// 🔵 Non-blocking, event-driven networking for Swift. Used for custom executors
1313
.package(url: "https://github.com/apple/swift-nio.git", from: "2.65.0"),
14-
.package(url: "https://github.com/GetAutomaApp/AutomaUtilities", branch: "main"),
14+
.package(url: "https://github.com/GetAutomaApp/AutomaUtilities.git", branch: "main"),
1515
],
1616
targets: [
1717
.executableTarget(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"autoscaler:creator": "cd ./SeleniumGridNodeMachineAutoscaler/ ; swift run SeleniumGridNodeMachineAutoscaler autocreator",
1616
"autoscaler:off_machines_destroyer": "cd ./SeleniumGridNodeMachineAutoscaler/ ; swift run SeleniumGridNodeMachineAutoscaler autodestroyer offMachines",
1717
"autoscaler:old_machines_destroyer": "cd ./SeleniumGridNodeMachineAutoscaler/ ; swift run SeleniumGridNodeMachineAutoscaler autodestroyer oldMachines",
18-
"deploy": "fly deploy --ha=false",
18+
"deploy": "flyctl deploy --ha=false",
1919
"deploy:autoscaler": "cd ./SeleniumGridNodeMachineAutoscaler && npm run deploy -- ./SeleniumGridNodeMachineAutoscaler/ --config=./infra/autoscaler.toml --build-secret GITHUB_SSH_AUTHENTICATION_TOKEN=$(cat ./infra/GITHUB_SSH_AUTHENTICATION_TOKEN)"
2020
},
2121
"repository": {

0 commit comments

Comments
 (0)