Skip to content

Commit

Permalink
Merge pull request #70 from GoliathLabs/gh-action
Browse files Browse the repository at this point in the history
Now using the metadata action for tags & labels
  • Loading branch information
GoliathLabs authored Jan 25, 2022
2 parents 32c4d8c + d0dc6d6 commit f0f9df0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
pull_request:
types: [opened, synchronize, reopened]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
Expand All @@ -18,12 +21,16 @@ jobs:
uses: docker/setup-qemu-action@v1
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1

- name: Get Docker image metadata
- name: Retrieve author data
run: |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo DATE=$(date --rfc-3339=seconds) >> $GITHUB_ENV
echo AUTHOR=$(curl -sSL ${{ github.event.repository.owner.url }} | jq -r '.name') >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.authors=${{ env.AUTHOR }}
- name: Build Docker image
uses: docker/build-push-action@v2
with:
Expand All @@ -33,11 +40,9 @@ jobs:
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: wg-access-server:testing
labels: |
org.opencontainers.image.created=${{ env.DATE }}
org.opencontainers.image.authors=${{ env.AUTHOR }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
org.opencontainers.image.authors: ${{ env.AUTHOR }}

- name: Inspect Docker image
run: docker image inspect wg-access-server:testing
run: docker image inspect ${{ steps.meta.outputs.tags }}
28 changes: 16 additions & 12 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
tags:
- 'v*.*.*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
push_to_registry:
name: Push Docker image to GitHub Packages
Expand All @@ -23,16 +27,21 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v1
with:
registry: ghcr.io
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Docker image metadata
- name: Retrieve author data
run: |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo DATE=$(date --rfc-3339=seconds) >> $GITHUB_ENV
echo AUTHOR=$(curl -sSL ${{ github.event.repository.owner.url }} | jq -r '.name') >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.authors=${{ env.AUTHOR }}
- name: Build container image
uses: docker/build-push-action@v2
with:
Expand All @@ -41,10 +50,5 @@ jobs:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest
labels: |
org.opencontainers.image.created=${{ env.DATE }}
org.opencontainers.image.authors=${{ env.AUTHOR }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit f0f9df0

Please sign in to comment.