-
Notifications
You must be signed in to change notification settings - Fork 1
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
cb6bc0b
commit e459993
Showing
1 changed file
with
21 additions
and
41 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 |
---|---|---|
@@ -1,53 +1,33 @@ | ||
--- | ||
name: Docker-build-release | ||
name: Update image in GHCR | ||
|
||
run-name: > | ||
${{ | ||
github.event_name == 'delete' && format( | ||
'Delete `{0}{1}`', | ||
github.event.ref_type == 'branch' && 'branch-' || '', | ||
github.event.ref | ||
) | ||
|| github.ref == 'refs/heads/main' && 'Update `dev`' | ||
|| format( | ||
'Update `{0}{1}`', | ||
!startsWith(github.ref, 'refs/tags') && 'branch-' || '', | ||
github.ref_name | ||
) | ||
}} docker tag | ||
on: | ||
push: | ||
branches: ['main'] | ||
branches-ignore: ['gh-pages'] | ||
tags: ['v*'] | ||
release: | ||
types: [published] | ||
delete: | ||
|
||
jobs: | ||
build-and-push-image: | ||
push-or-delete-image: | ||
runs-on: ubuntu-latest | ||
name: A job to build and push a docker image | ||
name: Update GitHub Container Registry | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Read YAML | ||
id: yaml-data | ||
uses: jbutcher5/[email protected] | ||
with: | ||
file: metadata.yaml | ||
key-path: '["image_name"]' | ||
|
||
- name: Create tags | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
flavor: | | ||
latest=false | ||
images: ghcr.io/uclahs-cds/${{ steps.yaml-data.outputs.data }} | ||
tags: | | ||
type=raw,enable=${{github.event_name == 'push'}},value=dev,event=branch | ||
type=match,pattern=v(.*),group=1 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io/uclahs-cds | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
file: ./docker/Dockerfile | ||
- uses: uclahs-cds/tool-Docker-action@v2 |