mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-02 14:35:25 +00:00
cec46716b6
Sometimes we want people to test features in PRs and not everyone is used to using git, build go and docker. This commit builds docker containers and pushes them to GHCR (not dockerhub) for testing on pushes to branches that has open pull requests to main using Ko. This is configured to mimic the debug images produced by goreleaser. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: Build Docker images for PRs
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-$${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions: write-all
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: dorny/paths-filter@v3
|
|
with:
|
|
filters: |
|
|
files:
|
|
- '*.nix'
|
|
- 'go.*'
|
|
- '**/*.go'
|
|
- 'integration_test/'
|
|
- 'config-example.yaml'
|
|
- uses: DeterminateSystems/nix-installer-action@main
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
|
|
- uses: actions/github-script@v6
|
|
id: get_pr_data
|
|
with:
|
|
script: |
|
|
return (
|
|
await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
|
commit_sha: context.sha,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
})
|
|
).data[0];
|
|
|
|
- name: Run ko build
|
|
id: build
|
|
if: steps.changed-files.outputs.files == 'true'
|
|
env:
|
|
KO_DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/headscale
|
|
run: |
|
|
ko build --tags=pr-${{ fromJson(steps.get_pr_data.outputs.result).number }},${{ github.sha }} ./cmd/headscale
|