-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
632af42
commit 3090809
Showing
3 changed files
with
76 additions
and
50 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 |
---|---|---|
|
@@ -21,7 +21,7 @@ jobs: | |
|
||
build: | ||
|
||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 20 | ||
permissions: | ||
packages: write | ||
|
@@ -37,29 +37,22 @@ jobs: | |
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}${{ env.ISPG_IMAGE }} | ||
# Before tests pass, we tag the image by the branch name | ||
# or by pull request number, e.g. pr-11 | ||
# https://github.com/docker/metadata-action#tags-input | ||
# See the release workflow for the release tags. | ||
tags: | | ||
type=sha | ||
type=ref,event=pr | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build image | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
tags: ${{ steps.meta.outputs.tags }} | ||
push: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
outputs: | | ||
type=registry,push-by-digest=true,name-canonical=true | ||
test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 10 | ||
permissions: | ||
packages: read | ||
|
@@ -87,40 +80,14 @@ jobs: | |
# Image that was build in the build workflow | ||
ISPG_IMAGE: ${{ env.ISPG_IMAGE }}@${{ needs.build.outputs.image_digest }} | ||
|
||
release: | ||
if: >- | ||
github.repository_owner == 'ispg-group' | ||
&& (github.ref_type == 'tag' || github.ref_name == 'main') | ||
needs: | ||
- build | ||
- test | ||
release-ghcr: | ||
if: github.repository_owner == 'ispg-group' | ||
needs: [build, test] | ||
uses: ./.github/workflows/publish.yml | ||
with: | ||
image_digest: ${{ needs.build.outputs.image_digest}} | ||
registry: ghcr.io | ||
secrets: inherit | ||
permissions: | ||
packages: write | ||
contents: write | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}${{ env.ISPG_IMAGE }} | ||
tags: | | ||
type=edge | ||
type=raw,value={{tag}},enable=${{ github.ref_type == 'tag' && ! startsWith(github.ref_name, 'v') }} | ||
type=match,pattern=v(\d{4}\.\d{2}.\d+(-.+)?),group=1 | ||
- name: Release image | ||
uses: akhilerm/[email protected] | ||
with: | ||
src: ${{ env.REGISTRY }}${{ env.ISPG_IMAGE }}@${{ needs.build.outputs.image_digest }} | ||
dst: ${{ steps.meta.outputs.tags }} |
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,60 @@ | ||
--- | ||
name: Publish images to Docker container registries | ||
|
||
env: | ||
# https://github.com/docker/metadata-action?tab=readme-ov-file#environment-variables | ||
DOCKER_METADATA_PR_HEAD_SHA: true | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image_digest: | ||
description: Digest of image built in build step | ||
required: true | ||
type: string | ||
registry: | ||
description: Docker container registry | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
|
||
release: | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 30 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Login to GitHub Container Registry 🔑 | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to DockerHub 🔑 | ||
uses: docker/login-action@v3 | ||
if: inputs.registry == 'docker.io' | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
env: ${{ fromJSON(steps.build_vars.outputs.vars) }} | ||
with: | ||
# e.g. ghcr.io/aiidalab/full-stack | ||
images: ${{ inputs.registry }}/${{ env.ISPG_IMAGE }} | ||
tags: | | ||
type=ref,event=pr | ||
type=edge,enable={{is_default_branch}} | ||
type=match,pattern=v(\d{4}\.\d{2}.\d+(-.+)?),group=1 | ||
- name: Push image | ||
uses: akhilerm/[email protected] | ||
with: | ||
src: ${{ inputs.registry }}/${{ env.ISPG_IMAGE }}@${{ inputs.image_digest }} | ||
dst: ${{ steps.meta.outputs.tags }} |
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