1+ name : Publish Containers
2+
3+ permissions :
4+ contents : read
5+ packages : write
6+
7+ on :
8+ push :
9+ tags :
10+ - ' *'
11+
12+ # Allows manual triggering of the workflow
13+ workflow_dispatch :
14+ inputs :
15+ tag :
16+ description : ' Tag release (e.g. v1.2.3)'
17+ required : true
18+
19+ # allow for testing of PR updating this file
20+ pull_request :
21+ paths :
22+ - " .github/workflows/containers.yaml"
23+
24+ jobs :
25+ build-and-push :
26+ runs-on : ubuntu-latest
27+ steps :
28+ - name : Checkout code
29+ uses : actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # 4.3.0
30+ with :
31+ fetch-depth : 0
32+ ref : ${{ github.event.inputs.tag || github.ref }}
33+
34+ - name : Log in to GitHub Container Registry
35+ uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # 3.5.0
36+ with :
37+ registry : ghcr.io
38+ username : ${{ github.actor }}
39+ password : ${{ secrets.GITHUB_TOKEN }}
40+
41+ - name : Determine docker image tags
42+ id : image_tags
43+ run : |
44+ # For PRs to this file tag the container "pull_request_test"
45+ if [ "${{ github.event_name }}" = "pull_request" ]; then
46+ echo "tags=ghcr.io/tailscale/tsidp:pull_request_test" >> $GITHUB_OUTPUT
47+ exit 0
48+ fi
49+
50+ # For tag push: use the tag name and also push "latest"
51+ if [ "${{ github.event_name }}" = "push" ]; then
52+ REF="${{ github.ref }}"
53+ TAG="${REF#refs/tags/}"
54+ echo "tags=ghcr.io/tailscale/tsidp:${TAG},ghcr.io/tailscale/tsidp:latest" >> $GITHUB_OUTPUT
55+ exit 0
56+ fi
57+
58+ # For workflow_dispatch: use the provided tag
59+ TAG="${{ github.event.inputs.tag }}"
60+ echo "tags=ghcr.io/tailscale/tsidp:${TAG}" >> $GITHUB_OUTPUT
61+
62+ - name : Set up Docker Buildx
63+ uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # 3.11.1
64+
65+ - name : Build and push
66+ uses : docker/build-push-action@v5
67+ with :
68+ context : .
69+ file : ./Dockerfile
70+ push : ${{ github.event_name != 'pull_request' }}
71+ tags : ${{ steps.image_tags.outputs.tags }}
72+ platforms : linux/amd64,linux/arm64
0 commit comments