Merge pull request #522 from ngrok/hkatz/update-readme #338
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`) |