Publish to GitHub Container Registry.

This commit is contained in:
Gareth Latty
2020-11-08 22:15:33 +00:00
parent f5ce909269
commit d7e5e33f0c
3 changed files with 100 additions and 73 deletions
+87
View File
@@ -0,0 +1,87 @@
name: Build
on:
push:
branches:
- main
tags:
- v*.*.*
env:
COMMIT_VERSION: "${{ github.sha }}-dev"
jobs:
build:
name: Build docker images.
runs-on: ubuntu-latest
strategy:
matrix:
component: ["server", "client"]
env:
COMPONENT: ${{ matrix.component }}
steps:
- name: Checkout repository.
uses: actions/checkout@v2
- name: Get version from tag.
uses: olegtarasov/get-tag@v2
continue-on-error: true
- name: Build image.
run:
cd "${COMPONENT}" &&
docker build -t "${COMPONENT}:${COMMIT_VERSION}"
--build-arg VCS_REF="${GITHUB_SHA}"
--build-arg BUILD_DATE="$(date --rfc-3339=seconds)"
--build-arg VERSION="${GITHUB_TAG_NAME:-${COMMIT_VERSION}}"
.
- name: Save image.
run: docker save "${COMPONENT}:${COMMIT_VERSION}" | gzip > "image.tar.gz"
- name: Store image for publish job.
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.component }}
path: image.tar.gz
publish:
name: Publish docker images.
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
component: ["server", "client"]
registry: [
{
server: "registry.hub.docker.com",
user: "latty",
token-secret: "DOCKER_HUB_TOKEN",
path: "massivedecks",
image-prefix: ""
},
{
server: "ghcr.io",
user: "lattyware",
token-secret: "GHCR_TOKEN",
path: "lattyware/massivedecks",
image-prefix: ""
}
]
steps:
- name: Retrieve image from build job.
uses: actions/download-artifact@v2
with:
name: ${{ matrix.component }}
- name: Load image.
run: docker load < "image.tar.gz"
- name: Get version from tag.
uses: olegtarasov/get-tag@v2
- name: Publish image.
uses: lattyware/push-docker-image-to-version-tags@v2
with:
source: "${{ matrix.component }}:${{ env.COMMIT_VERSION }}"
image: "${{ matrix.registry.image-prefix }}${{ matrix.component }}"
hash: "${{ env.COMMIT_VERSION }}"
version: "${{ env.GIT_TAG_NAME }}"
server: "${{ matrix.registry.server }}"
server_path: "${{ matrix.registry.path }}"
user: "${{ matrix.registry.user }}"
token: "${{ secrets[matrix.registry.token-secret] }}"
@@ -1,70 +0,0 @@
name: Build and publish docker images.
on:
push:
branches:
- master
tags:
- v*.*.*
env:
COMMIT_VERSION: "${{ github.sha }}-dev"
jobs:
build:
name: Build docker images.
runs-on: ubuntu-latest
strategy:
matrix:
component: ["server", "client"]
env:
COMPONENT: ${{ matrix.component }}
steps:
- name: Checkout repository.
uses: actions/checkout@v2
- name: Get version from tag.
uses: olegtarasov/get-tag@v1
continue-on-error: true
- name: Build image.
run:
cd "${COMPONENT}" &&
docker build -t "massivedecks/${COMPONENT}:${COMMIT_VERSION}"
--build-arg VCS_REF="${GITHUB_SHA}"
--build-arg BUILD_DATE="$(date --rfc-3339=seconds)"
--build-arg VERSION="${GITHUB_TAG_NAME:-${COMMIT_VERSION}}"
.
- name: Save image.
run: docker save "massivedecks/${COMPONENT}:${COMMIT_VERSION}" | gzip > "image.tar.gz"
- name: Store image for publish job.
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.component }}
path: image.tar.gz
publish:
name: Publish docker images.
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
COMPONENT: ["server", "client"]
env:
COMPONENT: ${{ matrix.component }}
steps:
- name: Retrieve image from build job.
uses: actions/download-artifact@v1
with:
name: ${{ matrix.component }}
- name: Load image.
run: docker load < "${COMPONENT}/image.tar.gz"
- name: Get version from tag.
uses: olegtarasov/get-tag@v1
- name: Publish image.
uses: lattyware/push-docker-image-to-version-tags@v1
with:
image: "massivedecks/${{ matrix.component }}"
tag: ${{ env.COMMIT_VERSION }}
version: ${{ env.GITHUB_TAG_NAME }}
user: "latty"
token: ${{ secrets.DOCKER_HUB_TOKEN }}
+13 -3
View File
@@ -1,6 +1,7 @@
# [Massive Decks ![Massive Decks](https://raw.githubusercontent.com/Lattyware/massivedecks/master/client/assets/images/icon.png)][hosted]
[![Build Status](https://img.shields.io/github/workflow/status/Lattyware/massivedecks/Build%20and%20publish%20docker%20images.)](https://github.com/Lattyware/massivedecks/actions)
[![Current Release Version](https://img.shields.io/github/v/tag/Lattyware/massivedecks?label=release&sort=semver)](https://github.com/Lattyware/massivedecks/releases)
[![Build Status](https://img.shields.io/github/workflow/status/Lattyware/massivedecks/Build)](https://github.com/Lattyware/massivedecks/actions)
[![License](https://img.shields.io/github/license/Lattyware/massivedecks)](LICENSE)
[![Follow on Twitter for Status & Updates](https://img.shields.io/twitter/follow/Massive_Decks?label=Status%20%26%20Updates&style=social)][twitter]
@@ -48,7 +49,9 @@ It is suggested you read the [deployment guide on the wiki][deployment-guide].
### Docker
The Docker images can be found on Docker Hub: [Server](https://hub.docker.com/r/massivedecks/server) / [Client](https://hub.docker.com/r/massivedecks/client).
The Docker images can be found on the GitHub Container Registry:
[Server](https://github.com/users/Lattyware/packages/container/package/massivedecks%2Fserver) /
[Client](https://github.com/users/Lattyware/packages/container/package/massivedecks%2Fclient).
There are example docker deployments in [the deployment folder](deployment).
@@ -75,9 +78,16 @@ The game has a system for translation, and if you would like to provide translat
## Credits
### Contributors
Massive Decks is open source, and would not be possible without the time and work of
[the community members][github-contributors] who have contributed code and localizations.
[github-contributors]: https://github.com/Lattyware/massivedecks/graphs/contributors
### Maintainers
Massive Decks is maintained by [Reread Games][reread].
[Reread Games][reread] maintains Massive Decks. If you enjoy Massive Decks, please take a look at their other games.
[reread]: https://www.rereadgames.com/