|
1 | 1 | name: Deploy Docs |
2 | 2 |
|
| 3 | +# Deploys the docs site (docs/) to the oss-infrastructure server via Kamal when a |
| 4 | +# release is published, or on demand. The build+deploy logic is shared across all |
| 5 | +# docs-kit sites — see mhenrixon/docs-kit/.github/workflows/deploy.yml. |
3 | 6 | on: |
4 | 7 | release: |
5 | 8 | types: [published] |
6 | 9 | workflow_dispatch: |
7 | 10 |
|
8 | | -concurrency: |
9 | | - group: deploy-docs |
10 | | - cancel-in-progress: false |
11 | | - |
12 | | -permissions: |
13 | | - contents: read |
14 | | - packages: write |
15 | | - |
16 | 11 | jobs: |
17 | | - build: |
18 | | - runs-on: ubuntu-latest |
19 | | - outputs: |
20 | | - image_tag: ${{ steps.tag.outputs.image_tag }} |
21 | | - |
22 | | - steps: |
23 | | - - uses: actions/checkout@v4 |
24 | | - |
25 | | - - name: Determine image tag |
26 | | - id: tag |
27 | | - env: |
28 | | - EVENT_NAME: ${{ github.event_name }} |
29 | | - RELEASE_TAG: ${{ github.event.release.tag_name }} |
30 | | - run: | |
31 | | - if [ "$EVENT_NAME" = "release" ]; then |
32 | | - TAG="$RELEASE_TAG" |
33 | | - else |
34 | | - TAG="sha-$(git rev-parse --short HEAD)" |
35 | | - fi |
36 | | - echo "image_tag=$TAG" >> "$GITHUB_OUTPUT" |
37 | | - echo "Building image tag: $TAG" |
38 | | -
|
39 | | - - name: Set up Docker Buildx |
40 | | - uses: docker/setup-buildx-action@v3 |
41 | | - |
42 | | - - name: Login to GitHub Container Registry |
43 | | - uses: docker/login-action@v3 |
44 | | - with: |
45 | | - registry: ghcr.io |
46 | | - username: ${{ github.actor }} |
47 | | - password: ${{ secrets.GITHUB_TOKEN }} |
48 | | - |
49 | | - - name: Build and push Docker image |
50 | | - uses: docker/build-push-action@v6 |
51 | | - with: |
52 | | - context: . |
53 | | - file: docs/Dockerfile |
54 | | - push: true |
55 | | - tags: | |
56 | | - ghcr.io/mhenrixon/daisyui:${{ steps.tag.outputs.image_tag }} |
57 | | - ghcr.io/mhenrixon/daisyui:latest |
58 | | - cache-from: type=registry,ref=ghcr.io/mhenrixon/daisyui:buildcache |
59 | | - cache-to: type=registry,ref=ghcr.io/mhenrixon/daisyui:buildcache,mode=max |
60 | | - |
61 | 12 | deploy: |
62 | | - needs: build |
63 | | - runs-on: ubuntu-latest |
64 | | - environment: docs |
65 | | - |
66 | | - steps: |
67 | | - - uses: actions/checkout@v4 |
68 | | - |
69 | | - - uses: ruby/setup-ruby@v1 |
70 | | - with: |
71 | | - ruby-version: "3.4" |
72 | | - bundler-cache: true |
73 | | - working-directory: docs |
74 | | - |
75 | | - - name: Setup SSH agent |
76 | | - uses: webfactory/ssh-agent@v0.9.1 |
77 | | - with: |
78 | | - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} |
79 | | - |
80 | | - - name: Configure SSH for the deploy host |
81 | | - env: |
82 | | - DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} |
83 | | - run: | |
84 | | - mkdir -p ~/.ssh |
85 | | - chmod 700 ~/.ssh |
86 | | - # Disable host-key verification for the deploy host. Kamal uses net-ssh, |
87 | | - # which raises HostKeyMismatch on any known_hosts conflict (e.g. after |
88 | | - # the server is reprovisioned). net-ssh honors ~/.ssh/config, so this |
89 | | - # turns verification off for this single known IP. Acceptable here: a |
90 | | - # public read-only docs site reached over an authenticated deploy key. |
91 | | - cat >> ~/.ssh/config <<EOF |
92 | | - Host $DEPLOY_HOST |
93 | | - StrictHostKeyChecking no |
94 | | - UserKnownHostsFile /dev/null |
95 | | - EOF |
96 | | - chmod 600 ~/.ssh/config |
97 | | -
|
98 | | - - name: Deploy with Kamal |
99 | | - working-directory: docs |
100 | | - env: |
101 | | - DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} |
102 | | - DEPLOY_DOMAIN: ${{ secrets.DEPLOY_DOMAIN }} |
103 | | - KAMAL_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
104 | | - IMAGE_TAG: ${{ needs.build.outputs.image_tag }} |
105 | | - run: | |
106 | | - bundle exec kamal deploy \ |
107 | | - --skip-push \ |
108 | | - --version="$IMAGE_TAG" |
| 13 | + uses: mhenrixon/docs-kit/.github/workflows/deploy.yml@main |
| 14 | + with: |
| 15 | + image: mhenrixon/daisyui |
| 16 | + service: daisyui |
| 17 | + secrets: inherit |
0 commit comments