2022-01-01 22:15:33 +01:00
|
|
|
name: Validate PR
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches: [ master ]
|
|
|
|
types: [assigned, opened, synchronize, labeled]
|
|
|
|
|
|
|
|
env:
|
|
|
|
IMAGE_TO_TEST: itzg/mc-router:test-${{ github.repository_owner }}-${{ github.run_id }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
|
|
|
|
steps:
|
2022-03-07 15:19:41 +01:00
|
|
|
- uses: actions/checkout@v3
|
2022-01-01 22:15:33 +01:00
|
|
|
|
|
|
|
- name: Setup Docker Buildx
|
2022-05-09 13:44:15 +02:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-01-01 22:15:33 +01:00
|
|
|
|
|
|
|
- name: Build
|
2022-07-25 03:29:07 +02:00
|
|
|
uses: docker/build-push-action@v3.1.0
|
2022-01-01 22:15:33 +01:00
|
|
|
with:
|
|
|
|
tags: ${{ env.IMAGE_TO_TEST }}
|
|
|
|
load: true
|
|
|
|
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
|
2022-05-09 13:44:54 +02:00
|
|
|
uses: docker/metadata-action@v4
|
2022-01-01 22:15:33 +01:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
itzg/mc-router
|
|
|
|
|
|
|
|
- name: Login to DockerHub
|
|
|
|
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
|
2022-05-09 13:44:41 +02:00
|
|
|
uses: docker/login-action@v2
|
2022-01-01 22:15:33 +01:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Push
|
|
|
|
if: contains(github.event.pull_request.labels.*.name, 'ci/push-image')
|
2022-07-25 03:29:07 +02:00
|
|
|
uses: docker/build-push-action@v3.1.0
|
2022-01-01 22:15:33 +01:00
|
|
|
with:
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
pull: true
|
|
|
|
push: true
|
|
|
|
cache-from: type=gha
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|