Skip to content

Commit

Permalink
Merge pull request #11 from chentex/release-build
Browse files Browse the repository at this point in the history
Adds build step for tagged image
  • Loading branch information
chentex authored Oct 26, 2020
2 parents 4cd21cb + 61cb24a commit d413333
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ jobs:
IMAGE_NAME="docker.io/chentex/random-logger"
echo ::set-output name=version::${VERSION}
echo ::set-output name=image::${IMAGE_NAME}
docker build --build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--build-arg VERSION="$VERSION" \
-f Dockerfile -t "$IMAGE_NAME":"$VERSION" .
docker build -f Dockerfile -t "$IMAGE_NAME":"$VERSION" .
- name: Scan for vulnerabilities
uses: aquasecurity/trivy-action@master
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*.*.*'
jobs:
docker:
name: Build and check for vulnerabilities
name: Build and release
runs-on: ubuntu-18.04
steps:
- name: Checkout code
Expand Down Expand Up @@ -47,4 +47,23 @@ jobs:
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/386
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
7 changes: 0 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
FROM alpine:3.12
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/chentex/random-logger" \
org.label-schema.version=$VERSION
RUN apk add --no-cache bc
COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
Expand Down

0 comments on commit d413333

Please sign in to comment.