mirror of
https://github.com/itzg/mc-router.git
synced 2024-11-22 11:35:14 +01:00
Simplify PR github action (#196)
This commit is contained in:
parent
de655ee432
commit
059ee78c5c
47
.github/workflows/pr.yml
vendored
47
.github/workflows/pr.yml
vendored
@ -3,54 +3,13 @@ name: Validate PR
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
types: [assigned, opened, synchronize, labeled]
|
|
||||||
|
|
||||||
env:
|
|
||||||
IMAGE_TO_TEST: itzg/mc-router:test-${{ github.repository_owner }}-${{ github.run_id }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v4
|
||||||
- name: Setup Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
uses: docker/build-push-action@v3.3.0
|
|
||||||
with:
|
with:
|
||||||
tags: ${{ env.IMAGE_TO_TEST }}
|
go-version-file: 'go.mod'
|
||||||
load: true
|
- run: go test ./...
|
||||||
cache-from: type=gha
|
|
||||||
target: builder
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
docker run --rm --entrypoint go ${{ env.IMAGE_TO_TEST }} test ./...
|
|
||||||
|
|
||||||
- name: Gather Docker metadata
|
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
itzg/mc-router
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Push
|
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
|
|
||||||
uses: docker/build-push-action@v3.3.0
|
|
||||||
with:
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
cache-from: type=gha
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: 1.20
|
go-version-file: 'go.mod'
|
||||||
|
|
||||||
- name: Setup docker buildx
|
- name: Setup docker buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
Loading…
Reference in New Issue
Block a user