diff --git a/.github/workflows/gha-summarizer.yaml b/.github/workflows/gha-summarizer.yaml index 6849121..eac5bfa 100644 --- a/.github/workflows/gha-summarizer.yaml +++ b/.github/workflows/gha-summarizer.yaml @@ -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: | diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..c4f24f9 --- /dev/null +++ b/action.yaml @@ -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