Added docker-workflow
This commit is contained in:
parent
626edfec9c
commit
b6f4f3d1f0
|
@ -6,21 +6,19 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
# Publish `v1.2.3` tags as releases.
|
release:
|
||||||
tags:
|
types: [published]
|
||||||
- v*
|
|
||||||
env:
|
env:
|
||||||
BUILD_VERSION: "2021.9.0"
|
BUILD_VERSION: ${{ github.ref }}
|
||||||
IMAGE_NAME: cloudflared
|
IMAGE_NAME: cloudflared
|
||||||
DOCKER_CLI_EXPERIMENTAL: enabled
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
||||||
REPOSITORY: ${{ github.actor }}/${{ github.workflow }}
|
REPOSITORY: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Push image to GitHub Packages.
|
# Push image to GitHub Packages.
|
||||||
# See also https://docs.docker.com/docker-hub/builds/
|
# See also https://docs.docker.com/docker-hub/builds/
|
||||||
push:
|
push:
|
||||||
# Ensure test job passes before pushing image.
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu:20.04
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Source checkout
|
- name: Source checkout
|
||||||
|
@ -34,17 +32,33 @@ jobs:
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: set version
|
||||||
|
run : |
|
||||||
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') #Get the tag or branch name (eg master or 2021.9.0)
|
||||||
|
REPOSITORY=$(echo $REPOSITORY | tr '[A-Z]' '[a-z]') #make all lowercase
|
||||||
|
# Strip "v" prefix from tag name or use short sha
|
||||||
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') || VERSION=$(git rev-parse --short "$GITHUB_SHA")
|
||||||
|
#Create a GA variable to use in other steps
|
||||||
|
echo "app_version=$VERSION" >> $GITHUB_ENV
|
||||||
|
echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set Docker metadata
|
- name: Set Docker metadata
|
||||||
id: docker_meta
|
id: docker_meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REPOSITORY }}
|
images: ${{ env.REPOSITORY }}
|
||||||
labels: |
|
labels: |
|
||||||
org.opencontainers.image.version=$VERSION
|
org.opencontainers.image.version=${{env.app_version }}
|
||||||
org.opencontainers.image.revision=${{ github.sha }}
|
org.opencontainers.image.revision=${{ github.sha }}
|
||||||
org.opencontainers.image.title=${{ env.REPOSITORY }}
|
org.opencontainers.image.title=${{ env.REPOSITORY }}
|
||||||
|
|
||||||
|
- name: GitHub login
|
||||||
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
uses: docker/login-action@v1.10.0
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: DockerHub login
|
- name: DockerHub login
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
uses: docker/login-action@v1.10.0
|
uses: docker/login-action@v1.10.0
|
||||||
|
@ -55,14 +69,13 @@ jobs:
|
||||||
uses: docker/build-push-action@v2.7.0
|
uses: docker/build-push-action@v2.7.0
|
||||||
with:
|
with:
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
context: ${{ github.workflow }}
|
platforms: linux/amd64
|
||||||
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le
|
build-args: ${{ env.app_version }}
|
||||||
build-args: $VERSION
|
|
||||||
cache-from: type=gha, scope=${{ github.workflow }}
|
cache-from: type=gha, scope=${{ github.workflow }}
|
||||||
cache-to: type=gha, scope=${{ github.workflow }}
|
cache-to: type=gha, scope=${{ github.workflow }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
tags: |
|
tags: |
|
||||||
docker.io/${{ env.REPOSITORY }}:${{ env.BUILD_VERSION }}
|
${{env.REPOSITORY}}:${{ env.app_version }}
|
||||||
docker.io/${{ env.REPOSITORY }}:latest
|
${{env.REPOSITORY}}:latest
|
||||||
ghcr.io/${{ env.REPOSITORY }}:${{ env.BUILD_VERSION }}
|
ghcr.io/${{ env.REPOSITORY }}:${{ env.app_version }}
|
||||||
ghcr.io/${{ env.REPOSITORY }}:latest
|
ghcr.io/${{ env.REPOSITORY }}:latest
|
||||||
|
|
Loading…
Reference in New Issue