Skip to content

Commit

Permalink
feat: Add new workflows (#34)
Browse files Browse the repository at this point in the history
* feat: Add new workflows

See this PR in
[publish_gem_to_github](actionshub/publish-gem-to-github#11)
for more details

Signed-off-by: Dan Webb <[email protected]>

* Update actions.yml

---------

Signed-off-by: Dan Webb <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
damacus and github-actions[bot] authored Feb 11, 2023
1 parent 0f4c796 commit a1960bd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
---
name: Build & Publish container
"on":
pull_request:
push:
branches: [main]

jobs:
publish:
build_and_publish:
name: Build & Publish to GitHub Container Registry
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Code checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Dry Run Bump version and push tag
id: dry_run_tag_version
if: github.event_name == 'pull_request'
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true

- name: Bump version and push tag
id: tag_version
if: github.ref == 'refs/heads/main'
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: false
dry_run: false

- name: Docker metadata
id: meta
Expand All @@ -36,23 +56,33 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@main
- name: Update actions.yml
if: github.event_name == 'pull_request'
uses: mikefarah/[email protected]
with:
cmd: yq e -i '.runs.image = "docker://ghcr.io/${{ github.repository }}:${{ steps.dry_run_tag_version.outputs.new_tag }}"' action.yml

- name: Commit Changes to actions.yml
if: github.event_name == 'pull_request'
uses: EndBug/add-and-commit@v9
with:
message: "Update actions.yml"
add: "action.yml"
default_author: github_actions

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.tag_version.outputs.new_tag }}
ghcr.io/${{ github.repository }}:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Create a GitHub release
if: github.ref == 'refs/heads/main'
uses: ncipollo/[email protected]
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
generateReleaseNotes: true
52 changes: 0 additions & 52 deletions .github/workflows/pull_request.yml

This file was deleted.

2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ outputs:
description: "stdout from mdl"
runs:
using: "docker"
image: "docker://ghcr.io/actionshub/markdownlint:v3.0.2"
image: "docker://ghcr.io/actionshub/markdownlint:v3.1.0"

0 comments on commit a1960bd

Please sign in to comment.