Skip to content

Commit

Permalink
Add GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
PhongT16 committed Sep 19, 2023
1 parent 7a0567b commit 7f584c2
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ghrc-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: GHCR Publish

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
workflow_dispatch:
push:
branches: [ "**" ]
# Publish semver tags as releases.
tags: [ 'v*' ]
#schedule:
# - cron: '30 15 * * *'
#pull_request:
# branches: [ main ]

env:
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
REGISTRY: "ghcr.io"


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# # Install the cosign tool except on PR
# # https://github.com/sigstore/cosign-installer
# - name: Install cosign
# if: github.event_name != 'pull_request'
# uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422
# with:
# cosign-release: 'v1.4.0'

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
"type=raw,value={{date 'X'}}_{{tag}}{{branch}}_{{sha}}"
"type=raw,value=latest"
"type=ref,event=tag"
"type=semver,pattern=v{{major}}"
"type=ref,event=branch"
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
with:
#context: "{{defaultContext}}:jiracmdline"
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 7f584c2

Please sign in to comment.