Skip to content

Commit

Permalink
Restructure workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
VOID404 committed Sep 7, 2024
1 parent 7f96c44 commit 050da46
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 51 deletions.
56 changes: 5 additions & 51 deletions .github/workflows/gha-summarizer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,27 @@ on:
paths-ignore:
- "README.md"
- "LICENSE"
pull_request_target:
pull_request:
branches:
- main
paths-ignore:
- "README.md"
- "LICENSE"

env:
image: ghcr.io/${{ github.repository }}/gha-summarizer

jobs:
build:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
outputs:
imageid: ${{ steps.docker_metadata.outputs.imageid }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Set up Docker metadata
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: ${{ github.event_name != 'pull_request_target' }}
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}

test-main:
test:
permissions:
contents: read
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Render template
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker://ghcr.io/void404/gha-summarizer/gha-summarizer:main
uses: ./
with:
args: example/template.md out.md
template: example/template.md
out-file: out.md

- name: Check if the rendered file is different
run: |
Expand Down
26 changes: 26 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "GHA Summarizer"
description: "Simple templating for Github Actions"
inputs:
template:
description: "Template to render"
required: true
out-file:
description: "File to write output to"
required: true
runs:
using: "composite"
steps:
- name: Checkout action code
uses: actions/checkout@v4
with:
ref: main
repository: ${{ github.action_repository }}

- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod

- name: Run templating
run: go run main.go ${{ inputs.template }} ${{ inputs.output }}
shell: bash

0 comments on commit 050da46

Please sign in to comment.