-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to build the parsec backend docker image
The image will be build on tag push or by manual trigger with `workflow_dispatch`. The image would have the following tags used: - `VERSION+{{ date 'YYYYMMDD' }}.sha.{{ short-sha }}` - `MAJOR.minor.patch` - `MAJOR.minor` Co-authored-by: Marcos Medrano <786907+mmmarcos@users.noreply.github.com>
- Loading branch information
1 parent
86ddeb1
commit 2da7c11
Showing
2 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Build & Publish Parsec Server Docker Image | ||
|
||
# cspell:words buildx | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- server/packaging/server/** | ||
- .github/workflows/docker-server.yml | ||
# Only run on pushed tag because we don't want this workflow to run everytime we push something to the main branch. | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+* | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner). | ||
# But outside of a PR, we want to have only 1 workflow to be run at the same time on a given git ref | ||
concurrency: | ||
group: docker-server-${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
docker-server: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin v4.1.1 | ||
timeout-minutes: 3 | ||
|
||
# Set up BuildKit Docker container builder to be able to build | ||
# multi-platform images and export cache | ||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
- name: Log in to the Github Container registry | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get current version | ||
id: version | ||
run: | | ||
sed -n 's/^.*Tool.Parsec: "\(.*\)",$/current=\1/p' misc/version_updater.py | tee $GITHUB_OUTPUT | ||
- name: Generate build metadata | ||
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 | ||
id: metadata | ||
with: | ||
images: | ||
ghcr.io/scille/parsec-cloud/parsec-server | ||
tags: | | ||
type=semver,pattern={{ version }} | ||
type=semver,pattern={{ major }}.{{ minor }} | ||
type=raw,value=${{ steps.version.outputs.current }}+{{ date 'YYYYMMDD' }}.sha.{{ sha }} | ||
flavor: | | ||
latest=${{ github.event_name == 'push' && github.ref_type == 'tag' }} | ||
- name: Image to be published | ||
run: echo ${{ steps.metadata.outputs.tags }} | ||
|
||
- name: Build and publish | ||
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | ||
id: build | ||
with: | ||
context: . | ||
file: server/packaging/server/server.dockerfile | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} | ||
push: ${{ (github.event_name == 'push' && github.ref_type == 'tag') || github.event_name == 'workflow_dispatch' }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters