github-workflow.yml RawHistoryFolder
1# Example GitHub Actions workflow for deploying to Gordon
2# Copy this file to your repository as .github/workflows/deploy.yml
3#
4# Prerequisites:
5# 1. Generate a Gordon token on your server:
6# gordon auth token generate --subject github-actions --scopes push,pull --expiry 0
7#
8# 2. Add these secrets to your GitHub repository:
9# - GORDON_REGISTRY: Your registry URL (e.g., registry.mydomain.com)
10# - GORDON_USERNAME: Token subject (e.g., github-actions)
11# - GORDON_TOKEN: The generated JWT token
12
13name: Deploy to Gordon
14
15on:
16 # Deploy on version tags
17 push:
18 tags:
19 - 'v*' # Matches v1.0.0, v2.1.3, etc.
20 - 'release-*' # Matches release-2024-01-15, etc.
21
22 # Optional: Allow manual deployments
23 workflow_dispatch:
24 inputs:
25 tag:
26 description: 'Tag/version to deploy (leave empty for latest commit)'
27 required: false
28 type: string
29
30jobs:
31 deploy:
32 runs-on: ubuntu-latest
33
34 # Optional: Only deploy from main branch for manual triggers
35 # if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
36
37 steps:
38 - name: Checkout code
39 uses: actions/checkout@v6
40 with:
41 # For manual dispatch with specific tag
42 ref: ${{ github.event.inputs.tag || github.ref }}
43
44 - name: Deploy to Gordon
45 id: deploy
46 uses: bnema/gordon/.github/actions/deploy@main
47 with:
48 registry: ${{ secrets.GORDON_REGISTRY }}
49 username: ${{ secrets.GORDON_USERNAME }}
50 password: ${{ secrets.GORDON_TOKEN }}
51 tag: ${{ github.event.inputs.tag }}
52 # Optional customizations:
53 # image: myapp # Custom image name (defaults to repo name)
54 # dockerfile: ./Dockerfile # Custom Dockerfile path
55 # context: . # Build context
56 # push-latest: 'true' # Also push :latest tag
57 # platforms: linux/amd64 # Target platform(s)
58
59 - name: Deployment summary
60 run: |
61 echo "## Deployment Complete" >> $GITHUB_STEP_SUMMARY
62 echo "" >> $GITHUB_STEP_SUMMARY
63 echo "**Image:** \`${{ steps.deploy.outputs.image }}\`" >> $GITHUB_STEP_SUMMARY
64 echo "**Tag:** \`${{ steps.deploy.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
65 echo "" >> $GITHUB_STEP_SUMMARY
66 echo "Gordon will automatically deploy this image to your configured routes." >> $GITHUB_STEP_SUMMARY
67
68# ============================================================================
69# ALTERNATIVE CONFIGURATIONS
70# ============================================================================
71
72# --- Deploy on push to main (continuous deployment) ---
73#
74# on:
75# push:
76# branches:
77# - main
78#
79# Then in the action, the image will be tagged with the commit SHA.
80
81# --- Deploy multiple services (monorepo) ---
82#
83# jobs:
84# deploy-api:
85# runs-on: ubuntu-latest
86# steps:
87# - uses: actions/checkout@v6
88# - uses: bnema/gordon/.github/actions/deploy@main
89# with:
90# registry: ${{ secrets.GORDON_REGISTRY }}
91# username: ${{ secrets.GORDON_USERNAME }}
92# password: ${{ secrets.GORDON_TOKEN }}
93# image: myapp-api
94# dockerfile: ./services/api/Dockerfile
95# context: ./services/api
96#
97# deploy-web:
98# runs-on: ubuntu-latest
99# steps:
100# - uses: actions/checkout@v6
101# - uses: bnema/gordon/.github/actions/deploy@main
102# with:
103# registry: ${{ secrets.GORDON_REGISTRY }}
104# username: ${{ secrets.GORDON_USERNAME }}
105# password: ${{ secrets.GORDON_TOKEN }}
106# image: myapp-web
107# dockerfile: ./services/web/Dockerfile
108# context: ./services/web
109
110# --- Deploy with build arguments ---
111#
112# - uses: bnema/gordon/.github/actions/deploy@main
113# with:
114# registry: ${{ secrets.GORDON_REGISTRY }}
115# username: ${{ secrets.GORDON_USERNAME }}
116# password: ${{ secrets.GORDON_TOKEN }}
117# build-args: |
118# NODE_ENV=production
119# API_URL=https://api.example.com
120# BUILD_DATE=${{ github.event.head_commit.timestamp }}
121
122# --- Multi-platform builds ---
123#
124# - uses: bnema/gordon/.github/actions/deploy@main
125# with:
126# registry: ${{ secrets.GORDON_REGISTRY }}
127# username: ${{ secrets.GORDON_USERNAME }}
128# password: ${{ secrets.GORDON_TOKEN }}
129# platforms: linux/amd64,linux/arm64