Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.git/
.github/
images/
testdata/

.gitignore
.ldignore
action.yml
CODEOWNERS

*.md
Makefile
35 changes: 35 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Docker image build
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
- name: Login to GitHub Container Registry
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push release image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
ghcr.io/${{ github.repository }}:latest
push: true
65 changes: 54 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '18.x'

- name: Install datadog-ci
run: npm install -g @datadog/datadog-ci
run: |
ddci_release="_$(uname -s | tr A-Z a-z)-$(uname -m | sed -e 's/^x86_64$/x64/' -e 's/^aarch64$/arm64/')"
gh release download --repo datadog/datadog-ci --pattern "*$ddci_release*" --clobber -O /usr/local/bin/datadog-ci
chmod +x /usr/local/bin/datadog-ci
env:
GH_TOKEN: ${{ github.token }}

- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.x'

- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod

Expand All @@ -42,7 +47,19 @@ jobs:
run: go mod tidy

- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
run: |
gotestsum_release="_$(uname -s | tr A-Z a-z)_$(uname -m | sed -e 's/^x86_64$/amd64/' -e 's/^aarch64$/arm64/')"
gh release download --repo gotestyourself/gotestsum --pattern "*$gotestsum_release*" --clobber -O /tmp/gotestsum.tar.gz
gh release download --repo gotestyourself/gotestsum --pattern "*-checksums.txt*" --clobber -O /tmp/gotestsum_checksums.txt
if [[ "$(sha256sum /tmp/gotestsum.tar.gz | cut -d ' ' -f 1)" != "$(grep -F "$gotestsum_release" /tmp/gotestsum_checksums.txt | cut -d ' ' -f 1)" ]]; then
echo "Checksum mismatch for gotestsum"
exit 1
fi
tar -xzf /tmp/gotestsum.tar.gz -C /usr/local/bin gotestsum
chmod +x /usr/local/bin/gotestsum
env:
GH_TOKEN: ${{ github.token }}


- name: Run tests with gotestsum
run: |
Expand Down Expand Up @@ -73,7 +90,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Swap full line for action to use Dockerfile
run: |
sed -i 's/image:.*/image: "Dockerfile"/' action.yml
- name: Find LaunchDarkly feature flags in diff
uses: ./ # Uses an action in the root directory
id: find-flags
Expand Down Expand Up @@ -118,10 +138,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.x'

Expand All @@ -131,7 +151,7 @@ jobs:
pip install pre-commit

- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '18.8.0'

Expand All @@ -140,4 +160,27 @@ jobs:

- name: Run pre-commit for GitHub Actions Docs
run: pre-commit run -a github-action-docs


build-image:
needs: [go-test, e2e-tests, generate-docs]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
- name: Docker Bake Action
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/launchdarkly/find-code-references-in-pull-request:latest
ghcr.io/launchdarkly/find-code-references-in-pull-request:${{ github.sha }}
push: ${{ github.ref == 'refs/heads/main' }}
24 changes: 15 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
ARG TARGETOS
ARG TARGETARCH

ENV GO111MODULE=on
WORKDIR /app

COPY . .

RUN go mod download
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build .

FROM golang:alpine

LABEL com.github.actions.name="LaunchDarkly Find Flags"
LABEL com.github.actions.description="Flags"
LABEL homepage="https://www.launchdarkly.com"

RUN apk update
RUN apk add --no-cache git

RUN mkdir /app
WORKDIR /app
COPY . .
ENV GO111MODULE=on
RUN go mod download
RUN go build .


COPY --from=builder /app/find-code-references-in-pull-request /usr/bin

ENTRYPOINT ["/app/find-code-references-in-pull-request"]
ENTRYPOINT ["find-code-references-in-pull-request"]
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 'LaunchDarkly Code References in Pull Request'
description: 'Find references to feature flags in your pull request'
runs:
using: 'docker'
image: 'Dockerfile'
image: 'ghcr.io/launchdarkly/find-code-references-action:v2.2.0'
env:
LD_PROJ_KEY: ${{ inputs.project-key }}
LD_ACCESS_TOKEN: ${{ inputs.access-token }}
Expand Down