name: build and push on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: name: Build and push runs-on: ubuntu-latest steps: - name: Set up Go 1.18 uses: actions/setup-go@v3 with: go-version: 1.18 id: go - name: Check out code into the Go module directory uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: lts/* - name: Setup yarn run: npm install -g yarn - name: Install dependencies run: yarn install working-directory: ./web - name: Compile JS and CSS run: yarn compile working-directory: ./web - name: Get dependencies run: go get -v -t -d ./... - name: Build run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v . - name: Login to Docker Hub if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }} uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Set up Docker Buildx if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }} uses: docker/setup-buildx-action@v1 - name: Build and push if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }} uses: docker/build-push-action@v2 with: context: . file: ./Dockerfile push: true tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sakuin:latest