Testing pipeline #3
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: golangci-lint | |
on: | |
push: | |
branches: | |
- feature/pipeline | |
pull_request: | |
permissions: | |
contents: read | |
# Optional: allow read access to pull request. Use with `only-new-issues` option. | |
# pull-requests: read | |
jobs: | |
golangci: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
cache: false | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: v1.54 | |
push_to_registry: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# Assign environment variables used in subsequent steps | |
- name: Env variable assignment | |
run: echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
# TAG_NAME defaults to 'latest' if not a release or manual deployment | |
- name: Assign version | |
run: | | |
echo "TAG_NAME=latest" >> $GITHUB_ENV | |
if [ "${{ github.event.release.tag_name }}" != "" ]; then | |
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
fi; | |
if [ "${{ github.event.inputs.version }}" != "" ]; then | |
echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
fi; | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Build and push new docker image, skip for manual redeploy other than 'latest' | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v3 | |
if: ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }} | |
with: | |
file: Dockerfile | |
context: . | |
push: true | |
tags: ghcr.io/${{ env.image_repository_name }}:${{ env.TAG_NAME }} |