Skip to content

Commit

Permalink
Merge pull request #357 from bblfsh/add-workflow
Browse files Browse the repository at this point in the history
chore: add github action workflow
  • Loading branch information
david972 authored Jul 5, 2023
2 parents 36f52d8 + 6f80049 commit fce3479
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19

- name: Test
run: go test -v -coverprofile=coverage.txt -covermode=atomic ./...

- name: Build
run: go build -v ./...

- name: coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: false # optional (default = false)
verbose: false # optional (default = false)

63 changes: 63 additions & 0 deletions .github/workflows/create_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on:
pull_request:
types: closed

jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
- uses: actions/checkout@v3
- name: Tag and prepare release
id: tag_and_prepare_release
uses: K-Phoen/semver-release-action@master
with:
release_branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload release notes
if: steps.tag_and_prepare_release.outputs.tag
uses: Roang-zero1/github-create-release-action@v3
with:
created_tag: ${{ steps.tag_and_prepare_release.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build variables
id: build_var
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
echo ::set-output name=BUILD_DATE::$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo ::set-output name=PROJECT_URL::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
echo ::set-output name=VCS_REF::$GITHUB_SHA
- name: Build and push Docker images
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
build-args: |
VERSION=${{ steps.tag_and_prepare_release.outputs.tag }}
VCS_REF=${{ steps.build_var.outputs.VCS_REF }}
BUILD_DATE=${{ steps.build_var.outputs.BUILD_DATE }}
PROJECT_URL=${{ steps.build_var.outputs.PROJECT_URL }}
tags: |
w6dio/bblfshd:${{ steps.tag_and_prepare_release.outputs.tag }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
14 changes: 14 additions & 0 deletions .github/workflows/enforce-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Enforce PR labels

on:
pull_request:
types: [labeled, unlabeled, opened, edited, synchronize]
jobs:
enforce-label:
runs-on: ubuntu-latest
steps:
- uses: yogevbd/[email protected]
with:
REQUIRED_LABELS_ANY: "major,minor,patch"
REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['major','minor','patch']"
BANNED_LABELS: "banned"
60 changes: 60 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release latest docker image

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}


- name: Build variables
id: build_var
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
echo ::set-output name=BUILD_DATE::$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo ::set-output name=PROJECT_URL::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
echo ::set-output name=VCS_REF::$GITHUB_SHA
- name: Build and push Docker images
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
build-args: |
VERSION=${{ steps.build_var.outputs.SOURCE_BRANCH }}
VCS_REF=${{ steps.build_var.outputs.VCS_REF }}
BUILD_DATE=${{ steps.build_var.outputs.BUILD_DATE }}
PROJECT_URL=${{ steps.build_var.outputs.PROJECT_URL }}
tags: |
w6dio/bblfshd:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

55 changes: 55 additions & 0 deletions .github/workflows/release_tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release docker image

on:
push:
tags:
- v*

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build variables
id: build_var
run: |
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/}
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
echo ::set-output name=BUILD_DATE::$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo ::set-output name=PROJECT_URL::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
echo ::set-output name=VCS_REF::$GITHUB_SHA
- name: Build and push Docker images
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
build-args: |
VERSION=${{ steps.build_var.outputs.SOURCE_TAG }}
VCS_REF=${{ steps.build_var.outputs.VCS_REF }}
BUILD_DATE=${{ steps.build_var.outputs.BUILD_DATE }}
PROJECT_URL=${{ steps.build_var.outputs.PROJECT_URL }}
tags: |
w6dio/bblfshd:${{ steps.build_var.outputs.SOURCE_TAG }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit fce3479

Please sign in to comment.