build images, deploy to docker and ghcr #1
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 | |
run-name: build images, deploy to docker and ghcr | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: build | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.20.8 | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: goreleaser check | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: curl -sfL https://git.io/goreleaser | sh -s -- check | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | |
- name: ghcr.io/prest/prest:beta | |
if: ${{ github.ref == 'refs/heads/main' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GORELEASER_GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | |
GITHUB_REF: ${GITHUB_REF} | |
run: bash ./scripts/docker-beta.sh | |
- name: docker release ghcr.io/prest/prest | |
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GORELEASER_GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | |
GITHUB_REF: ${GITHUB_REF} | |
run: bash ./scripts/docker-gh-tag.sh | |
- name: Login to Docker Registry | |
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_LOGIN }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: docker release in hub prest/prest | |
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') | |
env: | |
GITHUB_REF: ${GITHUB_REF} | |
run: bash ./scripts/docker-hub-tag.sh | |
- name: GoReleaser | |
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') | |
env: | |
DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GORELEASER_GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} | |
GITHUB_REF: ${GITHUB_REF} | |
run: bash ./scripts/releaser-tag.sh |