Skip to content
This repository has been archived by the owner on Oct 10, 2021. It is now read-only.

Commit

Permalink
Push image to GitHub Packages (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottBrenner committed Nov 7, 2020
1 parent 117def4 commit 9634178
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 38 additions & 1 deletion .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
pull_request:
branches: [ master ]

env:
IMAGE_NAME: generate-changelog-action

jobs:

build:
test:

runs-on: ubuntu-latest

Expand Down Expand Up @@ -46,3 +49,37 @@ jobs:
uses: docker://github/super-linter:v2.2.0
env:
VALIDATE_ALL_CODEBASE: true

# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test

runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into GitHub Container Registry
run: echo "${{ secrets.CHANGELOG_CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
SHA="${{ github.sha }}"
# Strip git ref prefix from version
REF=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
echo IMAGE_ID=$IMAGE_ID
echo SHA=$SHA
echo REF=$REF
docker tag $IMAGE_NAME $IMAGE_ID:$SHA
docker tag $IMAGE_NAME $IMAGE_ID:$REF
docker push $IMAGE_ID:$SHA
docker push $IMAGE_ID:$REF
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM alpine:3

LABEL org.opencontainers.image.source="https://github.com/ScottBrenner/generate-changelog-action"

RUN apk --no-cache add git nodejs-npm
RUN npm install -g generate-changelog

Expand Down

0 comments on commit 9634178

Please sign in to comment.