|
| 1 | +# Upstream Repository Workflow Configuration |
| 2 | + |
| 3 | +This document describes the GitHub Actions workflow that needs to be created in the main `alexjustesen/speedtest-tracker` repository to automatically trigger Docker image builds in this repository. |
| 4 | + |
| 5 | +## Required Workflow |
| 6 | + |
| 7 | +Create the following file in the speedtest-tracker repository: |
| 8 | + |
| 9 | +**File path**: `.github/workflows/trigger-docker-build.yml` |
| 10 | + |
| 11 | +```yaml |
| 12 | +name: Trigger Docker Image Build |
| 13 | + |
| 14 | +on: |
| 15 | + release: |
| 16 | + types: [published] |
| 17 | + |
| 18 | +jobs: |
| 19 | + trigger-docker-build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Generate GitHub App token |
| 24 | + id: generate_token |
| 25 | + uses: actions/create-github-app-token@v1 |
| 26 | + with: |
| 27 | + app-id: ${{ secrets.APP_ID }} |
| 28 | + private-key: ${{ secrets.APP_PRIVATE_KEY }} |
| 29 | + owner: alexjustesen |
| 30 | + repositories: docker-speedtest-tracker |
| 31 | + |
| 32 | + - name: Trigger docker-speedtest-tracker build |
| 33 | + uses: peter-evans/repository-dispatch@v3 |
| 34 | + with: |
| 35 | + token: ${{ steps.generate_token.outputs.token }} |
| 36 | + repository: alexjustesen/docker-speedtest-tracker |
| 37 | + event-type: speedtest-tracker-release |
| 38 | + client-payload: '{"tag_name": "${{ github.event.release.tag_name }}"}' |
| 39 | +``` |
| 40 | +
|
| 41 | +## Setup Requirements |
| 42 | +
|
| 43 | +### 1. Create a GitHub App |
| 44 | +
|
| 45 | +1. Go to GitHub Settings > Developer settings > GitHub Apps > New GitHub App |
| 46 | +2. Configure the app: |
| 47 | + - **Name**: Something like "Speedtest Tracker Docker Build" |
| 48 | + - **Homepage URL**: `https://github.com/alexjustesen/speedtest-tracker` |
| 49 | + - **Webhook**: Uncheck "Active" |
| 50 | + - **Permissions**: |
| 51 | + - Repository permissions > Contents: Read and write |
| 52 | + - **Where can this GitHub App be installed?**: Only on this account |
| 53 | +3. Click "Create GitHub App" |
| 54 | +4. Note the **App ID** (you'll need this) |
| 55 | +5. Scroll down to "Private keys" and click "Generate a private key" |
| 56 | +6. Save the downloaded `.pem` file |
| 57 | + |
| 58 | +### 2. Install the GitHub App |
| 59 | + |
| 60 | +1. On your GitHub App page, click "Install App" in the left sidebar |
| 61 | +2. Select your account (alexjustesen) |
| 62 | +3. Choose "Only select repositories" |
| 63 | +4. Select `docker-speedtest-tracker` |
| 64 | +5. Click "Install" |
| 65 | + |
| 66 | +### 3. Add Secrets to speedtest-tracker Repository |
| 67 | + |
| 68 | +1. Go to `https://github.com/alexjustesen/speedtest-tracker/settings/secrets/actions` |
| 69 | +2. Add the following secrets: |
| 70 | + - **Name**: `APP_ID` |
| 71 | + - **Value**: The App ID from step 1.4 |
| 72 | + - **Name**: `APP_PRIVATE_KEY` |
| 73 | + - **Value**: The entire contents of the `.pem` file (including `-----BEGIN RSA PRIVATE KEY-----` and `-----END RSA PRIVATE KEY-----`) |
| 74 | + |
| 75 | +## How It Works |
| 76 | + |
| 77 | +1. When a new release is published in `alexjustesen/speedtest-tracker` |
| 78 | +2. This workflow triggers automatically |
| 79 | +3. It sends a `repository_dispatch` event to `alexjustesen/docker-speedtest-tracker` |
| 80 | +4. The event includes the release tag name in the payload |
| 81 | +5. The docker repository's `release.yml` workflow receives the event and builds the Docker image |
| 82 | + |
| 83 | +## Alternative: Using Personal Access Token (PAT) |
| 84 | + |
| 85 | +If you prefer a simpler setup (though less secure for organizations), you can use a Personal Access Token: |
| 86 | + |
| 87 | +**Workflow:** |
| 88 | +```yaml |
| 89 | +name: Trigger Docker Image Build |
| 90 | +
|
| 91 | +on: |
| 92 | + release: |
| 93 | + types: [published] |
| 94 | +
|
| 95 | +jobs: |
| 96 | + trigger-docker-build: |
| 97 | + runs-on: ubuntu-latest |
| 98 | +
|
| 99 | + steps: |
| 100 | + - name: Trigger docker-speedtest-tracker build |
| 101 | + uses: peter-evans/repository-dispatch@v3 |
| 102 | + with: |
| 103 | + token: ${{ secrets.DOCKER_REPO_PAT }} |
| 104 | + repository: alexjustesen/docker-speedtest-tracker |
| 105 | + event-type: speedtest-tracker-release |
| 106 | + client-payload: '{"tag_name": "${{ github.event.release.tag_name }}"}' |
| 107 | +``` |
| 108 | + |
| 109 | +**Setup:** |
| 110 | +1. Create a Personal Access Token with `repo` scope |
| 111 | +2. Add it as a secret named `DOCKER_REPO_PAT` in the speedtest-tracker repository |
| 112 | + |
| 113 | +Note: GitHub Apps are recommended over PATs for better security, audit logging, and fine-grained permissions. |
| 114 | + |
| 115 | +## Testing |
| 116 | + |
| 117 | +To test the workflow without creating a release: |
| 118 | + |
| 119 | +1. Trigger manually using workflow_dispatch in the docker repository |
| 120 | +2. Go to `https://github.com/alexjustesen/docker-speedtest-tracker/actions/workflows/release.yml` |
| 121 | +3. Click "Run workflow" |
| 122 | +4. Enter a release tag (e.g., `v0.1.0`) |
| 123 | +5. Verify the build completes successfully |
| 124 | + |
| 125 | +## Expected Behavior |
| 126 | + |
| 127 | +When a release like `v0.1.0` is published in speedtest-tracker: |
| 128 | +- Docker images will be built for `linux/amd64` and `linux/arm64` |
| 129 | +- Images will be tagged as: |
| 130 | + - `ghcr.io/alexjustesen/docker-speedtest-tracker:0.1.0` |
| 131 | + - `ghcr.io/alexjustesen/docker-speedtest-tracker:0.1` |
| 132 | + - `ghcr.io/alexjustesen/docker-speedtest-tracker:0` |
| 133 | + - `ghcr.io/alexjustesen/docker-speedtest-tracker:latest` |
0 commit comments