-
Notifications
You must be signed in to change notification settings - Fork 368
97 lines (82 loc) · 2.51 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
88
89
90
91
92
93
94
95
96
97
---
name: Deploy
on:
workflow_dispatch:
push:
branches:
- main
jobs:
Docker:
if: ${{ github.repository_owner == 'beam-community' }}
runs-on: ubuntu-latest
outputs:
image: ${{ steps.outputs.outputs.image }}
tag: ${{ steps.outputs.outputs.tag }}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- id: metadata
name: Get Metadata
uses: docker/metadata-action@v5
with:
flavor: |
latest=auto
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
ghcr.io/${{ github.repository }}
tags: |
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login (GHCR)
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: build
name: Build
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
labels: ${{ steps.metadata.outputs.labels }}
platforms: linux/amd64
push: true
tags: ${{ steps.metadata.outputs.tags }}
- id: outputs
name: Get Outputs
uses: actions/github-script@v7
env:
BUILD_OUTPUT: ${{ steps.metadata.outputs.json }}
with:
script: |
const metadata = JSON.parse(process.env.BUILD_OUTPUT)
const shaUrl = metadata.tags.find((t) => t.includes(':sha-'))
if (shaUrl == null) {
core.error('Unable to find sha tag of image')
} else {
const [image, tag] = shaUrl.split(':')
core.setOutput('image', image)
core.setOutput('tag', tag)
}
Deploy:
if: ${{ github.repository_owner == 'beam-community' }}
runs-on: ubuntu-latest
needs: [Docker]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install (flyctl)
uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --yes --image "${{ needs.Docker.outputs.image }}:${{ needs.Docker.outputs.tag }}"
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}