name: release on: release: # Docs: types: [published] jobs: build: name: Build for ${{ matrix.os }} (${{ matrix.arch }}) runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: os: [linux, darwin] # linux, freebsd, darwin, windows arch: [amd64] # amd64, 386 steps: - uses: actions/setup-go@v2 with: {go-version: 1.17.5} - uses: actions/checkout@v2 - uses: gacts/github-slug@v1 id: slug - name: Generate builder values id: values run: echo "::set-output name=binary-name::error-pages-${{ matrix.os }}-${{ matrix.arch }}" - name: Build application env: GOOS: ${{ matrix.os }} GOARCH: ${{ matrix.arch }} CGO_ENABLED: 0 LDFLAGS: -s -w -X github.com/tarampampam/error-pages/internal/version.version=${{ steps.slug.outputs.version }} run: go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/error-pages/ - name: Upload binary file to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ steps.values.outputs.binary-name }} asset_name: ${{ steps.values.outputs.binary-name }} tag: ${{ github.ref }} docker-image: name: Build docker image runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - uses: gacts/github-slug@v1 id: slug - uses: docker/setup-qemu-action@v1 # Action page: - uses: docker/setup-buildx-action@v1 # Action page: - uses: docker/login-action@v1 # Action page: with: username: ${{ secrets.DOCKER_LOGIN }} password: ${{ secrets.DOCKER_PASSWORD }} - uses: docker/login-action@v1 # Action page: with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GHCR_PASSWORD }} - uses: docker/build-push-action@v2 # Action page: with: context: . file: Dockerfile push: true platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 build-args: "APP_VERSION=${{ steps.slug.outputs.version }}" tags: | tarampampam/error-pages:${{ steps.slug.outputs.version }} tarampampam/error-pages:latest ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }} ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:latest demo: name: Update the demonstration runs-on: ubuntu-20.04 needs: [docker-image] steps: - uses: gacts/github-slug@v1 id: slug - name: Take rendered templates from the built docker image run: | docker create --name img ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}:${{ steps.slug.outputs.version }} docker cp img:/opt/html ./out docker rm -f img - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./out