Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added GitHub Actions CI/CD + Updated Docker image
- Loading branch information
1 parent
59e3b89
commit bea8976
Showing
6 changed files
with
86 additions
and
16 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# GitHub Actions Workflow | ||
# To trigger the release pipeline create a new GitHub Release in the repository and set it as a pre-release. | ||
# This workflow requires a secret called CR_PAT which is a GitHub Personal Access Token with scope for GitHub Packages Read/Write | ||
|
||
name: CICD | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
# Note: GitHub Actions does not yet support IPv6 which is required to run the E2E tests so they have been disabled. | ||
# Note: Repository must be configured with secrets NDDNS_TEST_ZONE and NDDNS_TEST_ACCESS_TOKEN for propper function of the E2E test. | ||
# test: | ||
# strategy: | ||
# matrix: | ||
# os: [ubuntu-latest, macos-latest, windows-latest] | ||
# runs-on: ${{ matrix.os }} | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - name: Setup Go | ||
# uses: actions/setup-go@v2 | ||
# - name: Go Installation Information | ||
# run: go version | ||
# - name: Run E2E Tests | ||
# run: go test ./cmd | ||
# env: | ||
# NDDNS_DISABLE_ANALYTICS: true | ||
# NDDNS_TEST_ZONE: ${{ secrets.NDDNS_TEST_ZONE }} | ||
# NDDNS_TEST_ACCESS_TOKEN: ${{ secrets.NDDNS_TEST_ACCESS_TOKEN }} | ||
build-release: | ||
runs-on: ubuntu-latest | ||
# needs: test | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
- name: Which Go Version | ||
run: go version | ||
- name: Build Binaries For All Targets | ||
run: | | ||
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF#refs/tags/}" -o nddns_Linux ./cmd | ||
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.Version=${GITHUB_REF#refs/tags/}" -o nddns_Linux_Arm64 ./cmd | ||
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF#refs/tags/}" -o nddns_macOS ./cmd # TODO: Move this to exclusive Apple Silicon support after the transition is complete | ||
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.Version=${GITHUB_REF#refs/tags/}" -o nddns_Windows ./cmd | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: | | ||
nddns_Linux | ||
nddns_Linux_Arm64 | ||
nddns_macOS | ||
nddns_Windows | ||
docker-release: | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Authenticate with GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: oscartbeaumont | ||
password: ${{ secrets.CR_PAT }} | ||
- name: Build | ||
run: docker build --build-arg VERSION="${GITHUB_REF#refs/tags/}" -t "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_REF#refs/tags/}" . | ||
- name: Push | ||
run: docker push "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_REF#refs/tags/}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
FROM golang:alpine AS builder | ||
|
||
RUN adduser -D -g '' app | ||
ARG VERSION | ||
|
||
RUN adduser -D -g '' nddns_usr | ||
|
||
RUN apk update && \ | ||
apk add --no-cache git ca-certificates && \ | ||
update-ca-certificates | ||
|
||
RUN wget https://raw.githubusercontent.com/golang/dep/master/install.sh && \ | ||
sh install.sh | ||
|
||
WORKDIR $GOPATH/src/github.com/oscartbeaumont/netlify-dynamic-dns | ||
COPY Gopkg.toml Gopkg.lock ./ | ||
RUN dep ensure --vendor-only | ||
COPY . ./ | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o ./netlify-ddns ./cmd | ||
WORKDIR /src | ||
COPY . . | ||
RUN CGO_ENABLED=0 go build -ldflags "-X main.Version=${VERSION}" -o ./nddns ./cmd | ||
|
||
FROM scratch | ||
LABEL org.opencontainers.image.title Netlify Dynamic DNS | ||
LABEL org.opencontainers.image.source https://github.com/oscartbeaumont/netlify-dynamic-dns | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
USER app | ||
COPY --from=builder /go/src/github.com/oscartbeaumont/netlify-dynamic-dns/netlify-ddns ./netlify-ddns | ||
ENTRYPOINT ["./netlify-ddns"] | ||
USER nddns_usr | ||
COPY --from=builder /src/nddns / | ||
ENTRYPOINT ["/nddns"] |
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
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
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
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