Skip to content

Commit

Permalink
Automation for building,PR checking and Releasing by GitHub Actions (#8)
Browse files Browse the repository at this point in the history
* Create autobuild.yml

* solve docker repo for github packages

* remove space

* only master branch tags latest; ignore md changes.

* add release action

* ignore by paths-ignore

* add build badge

* add pr build check

* add name for jobs
  • Loading branch information
wangyoucao577 authored Mar 22, 2020
1 parent f57233f commit 03b2ba5
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/autobuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build Docker

on:
push:
branches:
- '**'
paths-ignore:
- '*.md'

jobs:

build:
name: Build & Publish Docker

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set DOCKER_REPO_NAME env
run: echo ::set-env name=DOCKER_REPO_NAME::$(basename ${GITHUB_REPOSITORY})
- name: Set IMAGE_TAG env
run: echo ::set-env name=IMAGE_TAG::$(basename ${GITHUB_REF})
- name: Environment Printer
uses: managedkaos/print-env@v1.0
- name: Append latest if master branches # env '${IMAGE_TAG},latest'
if: endsWith(github.ref, 'master')
run: echo ::set-env name=IMAGE_TAG::${IMAGE_TAG},latest
- name: Environment Printer
uses: managedkaos/print-env@v1.0

- name: Build & Publish to Github Package
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ${{ github.repository }}/${{ env.DOCKER_REPO_NAME }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
snapshot: false
tags: "${{ env.IMAGE_TAG }}"

- name: Build & Publish to DockerHub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ${{ github.repository }}
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
snapshot: false
tags: "${{ env.IMAGE_TAG }}"

20 changes: 20 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Build

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:

build:
name: PR Build & Check

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Environment Printer
uses: managedkaos/print-env@v1.0

- run: docker build .
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release Action Docker

on:
push:
tags:
- '**'

jobs:

build:
name: Release Action Docker

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set DOCKER_REPO_NAME env
run: echo ::set-env name=DOCKER_REPO_NAME::$(basename ${GITHUB_REPOSITORY})
- name: Set IMAGE_TAG env
run: echo ::set-env name=IMAGE_TAG::$(basename ${GITHUB_REF})
- name: Append latest for each release
run: echo ::set-env name=IMAGE_TAG::${IMAGE_TAG},latest
- name: Environment Printer
uses: managedkaos/print-env@v1.0

- name: Build & Publish to Github Package
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ${{ github.repository }}/${{ env.DOCKER_REPO_NAME }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
snapshot: false
tags: "${{ env.IMAGE_TAG }}"

- name: Build & Publish to DockerHub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: ${{ github.repository }}
username: ${{ github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
snapshot: false
tags: "${{ env.IMAGE_TAG }}"

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Go Release GitHub Action
# Go Release GitHub Action
![Build Docker](https://github.com/wangyoucao577/go-release-action/workflows/Build%20Docker/badge.svg)
Automatically publish `Go` binaries to Github Release Assets through Github Action.

## Features
Expand Down

0 comments on commit 03b2ba5

Please sign in to comment.