Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit f0c0910

Browse files
committed
BUILD/MAJOR: add autobuild script
1 parent 6a2cc79 commit f0c0910

File tree

2 files changed

+52
-46
lines changed

2 files changed

+52
-46
lines changed

.github/workflows/actions.yaml

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,14 @@
11
name: CI
2-
on: [push, pull_request]
2+
on: [pull_request]
33
jobs:
4-
go_lint:
5-
name: Go lint
6-
runs-on: ubuntu-latest
7-
steps:
8-
- uses: actions/checkout@v2
9-
- name: golangci-lint
10-
uses: golangci/golangci-lint-action@v2
11-
with:
12-
working-directory: check-commit
134
check_commit:
14-
if: ${{ github.event_name == 'pull_request' }}
155
name: HAProxy check commit message
166
runs-on: ubuntu-latest
177
steps:
188
- uses: actions/checkout@v2
199
with:
2010
fetch-depth: 0
2111
- name: check-commit
22-
uses: docker://haproxytech/check-commit:latest
12+
uses: docker://ghcr.io/haproxytech/commit-check:3.0.0
2313
env:
2414
API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
go_build:
26-
name: Go build
27-
runs-on: ubuntu-latest
28-
needs: ["go_lint"]
29-
steps:
30-
- name: Check out code into the Go module directory
31-
uses: actions/checkout@v2
32-
- name: Set up Go 1.17
33-
uses: actions/setup-go@v2
34-
with:
35-
go-version: 1.17
36-
id: go
37-
- name: Get dependencies
38-
run: |
39-
cd check-commit && go get -v -t -d ./...
40-
- name: Build
41-
run: |
42-
cd check-commit && go build -v .
43-
go_test:
44-
name: Go test
45-
runs-on: ubuntu-latest
46-
needs: ["go_lint"]
47-
steps:
48-
- uses: actions/checkout@v2
49-
- uses: actions/setup-go@v2
50-
with:
51-
go-version: 1.17
52-
id: go
53-
- name: Get dependencies
54-
run: |
55-
cd check-commit && go get -v -t -d ./...
56-
- name: Build
57-
run: |
58-
cd check-commit && go test ./...

.github/workflows/build_on_tag.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: ghcr.io image
2+
3+
on:
4+
push:
5+
# Publish `main` as Docker `latest` image.
6+
branches:
7+
- main
8+
9+
# Publish `v1.2.3` tags as releases.
10+
tags:
11+
- v*
12+
13+
env:
14+
IMAGE_NAME: go-linter
15+
16+
jobs:
17+
# Push image to GitHub Packages.
18+
# See also https://docs.docker.com/docker-hub/builds/
19+
push:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
packages: write
23+
contents: read
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
28+
- name: Build image
29+
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
30+
31+
- name: Log in to registry
32+
# This is where you will update the PAT to GITHUB_TOKEN
33+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
34+
35+
- name: Push image
36+
run: |
37+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
38+
39+
# Change all uppercase to lowercase
40+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
41+
# Strip git ref prefix from version
42+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
43+
# Strip "v" prefix from tag name
44+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
45+
# Use Docker `latest` tag convention
46+
[ "$VERSION" == "main" ] && VERSION=latest
47+
echo IMAGE_ID=$IMAGE_ID
48+
echo VERSION=$VERSION
49+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
50+
docker push $IMAGE_ID:$VERSION

0 commit comments

Comments
 (0)