Skip to content

CI: Update GitHub Action to build Docker container#181

Merged
xnyo merged 1 commit intomainfrom
giuseppe/gh-action-build-docker
Apr 5, 2024
Merged

CI: Update GitHub Action to build Docker container#181
xnyo merged 1 commit intomainfrom
giuseppe/gh-action-build-docker

Conversation

@xnyo
Copy link
Copy Markdown
Member

@xnyo xnyo commented Apr 2, 2024

Updates the GitHub Action test.yml so it builds the Docker container, rather than running the tests and build step directly inside GitHub Actions.

Right now, the GitHub Action is doing the same steps as the ones in the Dockerfile:

FROM golang:1.21-alpine as builder
WORKDIR /go/src/github.com/grafana/plugin-validator
ADD . /go/src/github.com/grafana/plugin-validator
RUN apk add --no-cache git ca-certificates curl && \
update-ca-certificates
RUN git clone https://github.com/magefile/mage --depth 1 && \
cd mage && \
go run bootstrap.go && \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
RUN cd /go/src/github.com/grafana/plugin-validator && \
mage -v build:ci && \
ls -al bin

With this PR, the GH action will trigger a Docker image build. This is better because whenever we change the build/test steps (or the golangci-lint, semgrep or gosec versions), we don't have to update the GH action workflow as well as the Dockerfile.

This is also the same approach used in the drone pipeline, where the "build + test + push" step simply builds the Docker container:

steps:
- image: plugins/docker
name: build + test + push
settings:
dry_run: true
password:
from_secret: docker-hub-password
repo: grafana/plugin-validator-cli
tags: latest
username:
from_secret: docker-hub-username

@xnyo xnyo requested review from a team as code owners April 2, 2024 10:07
@xnyo xnyo requested review from andresmgot, briangann, oshirohugo, sunker and wbrowne and removed request for a team April 2, 2024 10:07
@xnyo xnyo self-assigned this Apr 2, 2024
@xnyo xnyo added enhancement New feature or request github_actions Pull requests that update GitHub Actions code labels Apr 2, 2024
@xnyo xnyo merged commit cb55801 into main Apr 5, 2024
@xnyo xnyo deleted the giuseppe/gh-action-build-docker branch April 5, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request github_actions Pull requests that update GitHub Actions code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants