You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
push-to-ghcr
v2
This action simplifies pushes of Docker images to ghcr.io repository.
- On each
release
event (releases namedvx.y.z
) your image will be tagged withx.y.z
- On each
push
event your image will be tagged withlatest
Create a new GitHub Actions workflow as follows:
name: Build and publish a Docker image to ghcr.io
on:
# publish on releases (tagged as "x.y.z" - "v" prefix is removed)
release:
types: [ published ]
# publish on pushes to the main branch (tagged as "master")
push:
branches:
- master
jobs:
docker_publish:
runs-on: "ubuntu-20.04"
steps:
- uses: actions/checkout@v2
# https://github.com/marketplace/actions/push-to-ghcr
- name: Build and publish a Docker image for ${{ github.repository }}
uses: macbre/push-to-ghcr@v2
with:
image_name: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}
This action assumes that your Dockerfile
is in the root directory of your repository.
The image that is pushed is labelled with org.label-schema
and org.opencontainers
schema. For instance:
{
"org.label-schema.build-date": "2021-07-01T14:28:46Z",
"org.label-schema.vcs-ref": "6f51d3d7bb7d46959a26594cb2b807573e34c546",
"org.label-schema.vcs-url": "https://github.com/macbre/push-to-ghcr.git",
"org.opencontainers.image.created": "2021-07-01T14:28:46Z",
"org.opencontainers.image.revision": "6f51d3d7bb7d46959a26594cb2b807573e34c546",
"org.opencontainers.image.source": "https://github.com/macbre/push-to-ghcr.git"
}
Additonally, BUILD_DATE
and GITHUB_SHA
build args are set resulting with these env variables being present in the container:
BUILD_DATE=2021-07-01T12:52:03Z
GITHUB_SHA=26b095f37cdf56a632aa2235345d4174b26e1d66