Switch to using GitHub container registry
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
c0163bd9af
commit
cce5533437
86
.github/workflows/docker.yaml
vendored
86
.github/workflows/docker.yaml
vendored
@ -6,66 +6,34 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- v*
|
- v*
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-push-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
- name: Prepare
|
- name: Log in to the Container registry
|
||||||
id: prepare
|
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||||
run: |
|
|
||||||
DOCKER_IMAGE=averagemarcus/tailscale-exporter
|
|
||||||
DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
|
|
||||||
|
|
||||||
VERSION=latest
|
|
||||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
|
||||||
fi
|
|
||||||
|
|
||||||
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
|
|
||||||
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
||||||
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ::set-output name=tags::${TAGS}
|
|
||||||
echo ::set-output name=platforms::${DOCKER_PLATFORMS}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: crazy-max/ghaction-docker-buildx@v3
|
|
||||||
|
|
||||||
- name: Cache Docker layers
|
|
||||||
uses: actions/cache@v2
|
|
||||||
id: cache
|
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
registry: ${{ env.REGISTRY }}
|
||||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
username: ${{ github.actor }}
|
||||||
restore-keys: |
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
${{ runner.os }}-buildx-
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
- name: Docker Buildx (build)
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
run: |
|
with:
|
||||||
docker buildx build \
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
- name: Build and push Docker image
|
||||||
--cache-to "type=local,dest=/tmp/.buildx-cache" \
|
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||||
--platform ${{ steps.prepare.outputs.platforms }} \
|
with:
|
||||||
--output "type=image,push=false" \
|
context: .
|
||||||
${{ steps.prepare.outputs.tags }} \
|
push: true
|
||||||
.
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
- name: Docker Login
|
|
||||||
env:
|
|
||||||
DOCKER_USERNAME: averagemarcus
|
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }}
|
|
||||||
run: |
|
|
||||||
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
|
|
||||||
|
|
||||||
- name: Docker Buildx (push)
|
|
||||||
run: |
|
|
||||||
docker buildx build \
|
|
||||||
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
|
||||||
--cache-to "type=local,dest=/tmp/.buildx-cache" \
|
|
||||||
--platform ${{ steps.prepare.outputs.platforms }} \
|
|
||||||
--output "type=image,push=true" \
|
|
||||||
${{ steps.prepare.outputs.tags }} \
|
|
||||||
.
|
|
||||||
|
@ -23,7 +23,7 @@ The following environment variable can be used to configure the exporter:
|
|||||||
```shell
|
```shell
|
||||||
export TAILSCALE_API_KEY="my-tailscale-api-key"
|
export TAILSCALE_API_KEY="my-tailscale-api-key"
|
||||||
export TAILSCALE_TAILNET="my-tailnet.github"
|
export TAILSCALE_TAILNET="my-tailnet.github"
|
||||||
docker run --rm -it -p 8080:8080 -e TAILSCALE_API_KEY -e TAILSCALE_TAILNET averagemarcus/tailscale-exporter:latest
|
docker run --rm -it -p 8080:8080 -e TAILSCALE_API_KEY -e TAILSCALE_TAILNET ghcr.io/averagemarcus/tailscale-exporter:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Then visit: [http://localhost:8080/metrics](http://localhost:8080/metrics)
|
Then visit: [http://localhost:8080/metrics](http://localhost:8080/metrics)
|
||||||
@ -76,7 +76,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: tailscale-exporter
|
- name: tailscale-exporter
|
||||||
image: averagemarcus/tailscale-exporter:latest
|
image: ghcr.io/averagemarcus/tailscale-exporter:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
|
Loading…
Reference in New Issue
Block a user