add buildx to pipeline #164
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build and test | |
on: | |
push: | |
paths-ignore: | |
- '**/README.md' | |
- '**/README_DEV.md' | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: browser-actions/setup-chrome@latest | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '>=1.18.0' | |
# - name: Install dependencies | |
# run: go get -u golang.org/x/lint/golint | |
# - name: Run vet and lint | |
# run: | | |
# go vet . | |
# golint -set_exit_status=1 . | |
- run: go build | |
#- run: go test -timeout 120s ./... | |
- run: go test -race -coverprofile=coverage.out -covermode=atomic -timeout 120s ./... | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
publish-container: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
platform: [linux/amd64, linux/arm64] | |
needs: build-and-test | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Set version to env | |
run: | | |
echo "VERSION=$(date +'%Y.%-m.%-d.%-H%M')" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
# - run: git submodule update --init | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to Github Packages | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push docker image with playground | |
uses: docker/build-push-action@v2 | |
with: | |
platforms: ${{ matrix.platform }} | |
context: ./ | |
tags: | | |
lucasgaitzsch/pdf-turtle:latest | |
lucasgaitzsch/pdf-turtle:v${{ env.VERSION }} | |
ghcr.io/${{ github.repository }}:latest | |
ghcr.io/${{ github.repository }}:v${{ env.VERSION }} | |
lucasgaitzsch/pdf-turtle:latest-playground | |
lucasgaitzsch/pdf-turtle:v${{ env.VERSION }}-playground | |
ghcr.io/${{ github.repository }}:latest-playground | |
ghcr.io/${{ github.repository }}:v${{ env.VERSION }}-playground | |
push: true | |
- name: Build and push docker image with playground and unprivileged | |
uses: docker/build-push-action@v2 | |
with: | |
platforms: ${{ matrix.platform }} | |
file: ./Dockerfile.unprivileged | |
context: ./ | |
tags: | | |
lucasgaitzsch/pdf-turtle:latest-unprivileged | |
lucasgaitzsch/pdf-turtle:v${{ env.VERSION }}-unprivileged | |
ghcr.io/${{ github.repository }}:latest-unprivileged | |
ghcr.io/${{ github.repository }}:v${{ env.VERSION }}-unprivileged | |
push: true | |
- name: Build and push docker image without playground | |
uses: docker/build-push-action@v2 | |
with: | |
platforms: ${{ matrix.platform }} | |
file: ./Dockerfile.withoutPlayground | |
context: ./ | |
tags: | | |
lucasgaitzsch/pdf-turtle:latest-without-playground | |
lucasgaitzsch/pdf-turtle:v${{ env.VERSION }}-without-playground | |
ghcr.io/${{ github.repository }}:latest-without-playground | |
ghcr.io/${{ github.repository }}:v${{ env.VERSION }}-without-playground | |
push: true | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
DOCKERHUB_REPOSITORY: lucasgaitzsch/pdf-turtle | |
short-description: ${{ github.event.repository.description }} |