-
Notifications
You must be signed in to change notification settings - Fork 27
95 lines (91 loc) · 2.76 KB
/
docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Docker
on:
push:
branches:
- main
env:
DOCKER_BUILDX_PLATFORMS: linux/amd64,linux/arm64
jobs:
changes:
name: Changes
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
tag: ${{ steps.filter.outputs.tag }}
permissions:
contents: read
pull-requests: read
if: github.repository == 'ngrok/ngrok-operator'
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Check for changes
id: filter
uses: dorny/[email protected]
with:
filters: |
tag:
- 'VERSION'
release:
name: Release Images
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
needs:
- changes
if: |
github.repository == 'ngrok/ngrok-operator' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Extract Version tag
id: extract_tag
run: |
echo "tag=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- id: buildx-setup
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: ${{ env.DOCKER_BUILDX_PLATFORMS }}
- name: Build and push latest docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: ${{ steps.buildx-setup.outputs.platforms }}
push: true
tags: ngrok/ngrok-operator:latest
- name: Build and push tag'd docker image
uses: docker/build-push-action@v3
if: ${{ needs.changes.outputs.tag == 'true' }}
with:
context: .
platforms: ${{ steps.buildx-setup.outputs.platforms }}
push: true
tags: ngrok/ngrok-operator:${{ steps.extract_tag.outputs.tag }}
- name: Create GitHub Release
uses: actions/github-script@v6
if: ${{ needs.changes.outputs.tag == 'true' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = '${{ steps.extract_tag.outputs.tag }}'
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `ngrok-operator-${tag}`,
name: `ngrok-operator-${tag}`,
body: `${tag}`,
draft: false,
prerelease: false
})
console.log(`Release created: ${release.data.html_url}`)