Skip to content

Commit c88169a

Browse files
authored
Merge pull request #3 from bigcommerce/merge-upstream
Merge upstream commits
2 parents 6d2d53a + b3a8da5 commit c88169a

33 files changed

+1953
-933
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
charset = utf-8
11+
12+
[*.{yml, yaml}]
13+
indent_size = 2
14+
15+
[*.go]
16+
indent_style = tab
17+
18+
[Makefile]
19+
indent_style = tab

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ updates:
66
interval: "weekly"
77
reviewers:
88
- "Shopify/infrasec"
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
# Check for updates to GitHub Actions every week
13+
interval: "weekly"

.github/pull_request_template.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Pull Request Template
2+
3+
### Description
4+
Please provide a brief description of the changes in this PR.
5+
6+
### Type of Change
7+
- [ ] Bug fix (non-breaking change which fixes an issue)
8+
- [ ] New feature (non-breaking change which adds functionality)
9+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10+
- [ ] Documentation update
11+
- [ ] Code refactoring
12+
- [ ] Other (please describe):
13+
14+
### Testing
15+
- [ ] I have run `make pr-tests` and all tests pass
16+
- [ ] I have added tests that prove my fix is effective or that my feature works
17+
- [ ] New and existing unit tests pass locally with my changes
18+
19+
### Code Quality
20+
- [ ] My code follows the style guidelines of this project
21+
- [ ] I have performed a self-review of my own code
22+
- [ ] I have commented my code, particularly in hard-to-understand areas
23+
- [ ] I have made corresponding changes to the documentation
24+
25+
### Before Submitting
26+
Please ensure you have completed the following before submitting your PR:
27+
28+
```bash
29+
# Run comprehensive tests
30+
make pr-tests
31+
```
32+
33+
If the above command fails, please fix the issues before submitting your PR.
34+
35+
### Additional Notes
36+
Add any other context about the pull request here.

.github/workflows/docker-master.yaml

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,67 @@ on:
66

77
jobs:
88
build-and-push-docker-image:
9+
permissions:
10+
contents: read
11+
packages: write
12+
id-token: write
13+
914
name: Build Docker image and push to repositories with tag latest
1015
runs-on: ubuntu-latest
1116
steps:
1217
- name: Checkout code
13-
uses: actions/checkout@v2
14-
15-
- name: Set up QEMU
16-
uses: docker/setup-qemu-action@v1
17-
18-
- name: Set up Docker Buildx
19-
id: buildx
20-
uses: docker/setup-buildx-action@v1
21-
22-
- name: Docker meta
23-
id: meta
24-
uses: docker/metadata-action@v3
25-
with:
26-
images: |
27-
lablabs/cloudflare_exporter
28-
ghcr.io/lablabs/cloudflare_exporter
29-
# generate Docker tags based on the following events/attributes
30-
tags: type=raw,value=latest
31-
32-
- name: Login to DockerHub
33-
uses: docker/login-action@v1
34-
with:
35-
username: ${{ secrets.DOCKERHUB_USERNAME }}
36-
password: ${{ secrets.DOCKERHUB_TOKEN }}
18+
uses: actions/checkout@v5
3719

3820
- name: Login to Github Packages
39-
uses: docker/login-action@v1
21+
uses: docker/login-action@v3
4022
with:
4123
registry: ghcr.io
4224
username: ${{ github.repository_owner }}
4325
password: ${{ secrets.GITHUB_TOKEN }}
4426

45-
- name: Build image and push to Docker Hub and GitHub Container Registry
46-
uses: docker/build-push-action@v2
27+
28+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
4729
with:
48-
context: .
49-
file: ./Dockerfile
50-
platforms: linux/amd64,linux/arm64
51-
tags: ${{ steps.meta.outputs.tags }}
52-
labels: ${{ steps.meta.outputs.labels }}
53-
push: true
54-
55-
- name: Image digest
56-
run: echo ${{ steps.docker_build.outputs.digest }}
30+
go-version-file: "go.mod"
31+
cache: false
32+
33+
34+
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
35+
with:
36+
version: v0.18.0
37+
- name: Build and push
38+
id: publish-image
39+
env:
40+
KO_DOCKER_REPO: "ghcr.io/${{ github.repository }}"
41+
run: |
42+
ko build . --sbom=none --bare --platform linux/arm64,linux/amd64 -t latest \
43+
--image-label org.opencontainers.image.title=cloudflare-exporter \
44+
--image-label org.opencontainers.image.description="Prometheus CloudFlare Exporter" \
45+
--image-label org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} \
46+
--image-label org.opencontainers.image.revision=${{ github.sha }} \
47+
--image-label org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} \
48+
--image-label org.opencontainers.image.licenses=Apache-2.0 \
49+
--image-label org.opencontainers.image.version=latest \
50+
--image-label org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
51+
52+
distribute-to-dockerhub:
53+
runs-on: ubuntu-latest
54+
needs:
55+
- build-and-push-docker-image
56+
permissions:
57+
packages: read
58+
steps:
59+
- name: Copy image to dockerhub
60+
env:
61+
GHCR_REPO: "ghcr.io/${{ github.repository }}"
62+
GHCR_USERNAME: ${{ github.actor }}
63+
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
64+
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
65+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
66+
run: |
67+
docker run --rm quay.io/containers/skopeo:v1.18.0 \
68+
copy --multi-arch all \
69+
--src-creds "$GHCR_USERNAME:$GHCR_PASSWORD" \
70+
--dest-creds "$DOCKER_USERNAME:$DOCKER_TOKEN" \
71+
docker://${GHCR_REPO}:latest \
72+
docker://lablabs/cloudflare_exporter:latest

.github/workflows/docker-release.yaml

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,91 @@ on:
77

88
jobs:
99
build-and-push-docker-image:
10+
permissions:
11+
contents: read
12+
packages: write
13+
id-token: write
14+
attestations: write
15+
1016
name: Build Docker image and push to repositories with version tag
1117
runs-on: ubuntu-latest
1218
steps:
1319
- name: Checkout code
14-
uses: actions/checkout@v2
15-
16-
- name: Set up QEMU
17-
uses: docker/setup-qemu-action@v1
18-
19-
- name: Set up Docker Buildx
20-
id: buildx
21-
uses: docker/setup-buildx-action@v1
22-
23-
- name: Docker meta
24-
id: meta
25-
uses: docker/metadata-action@v3
26-
with:
27-
images: |
28-
lablabs/cloudflare_exporter
29-
ghcr.io/lablabs/cloudflare_exporter
30-
# generate Docker tags based on the following events/attributes
31-
tags: type=ref,event=tag
32-
33-
- name: Login to DockerHub
34-
uses: docker/login-action@v1
35-
with:
36-
username: ${{ secrets.DOCKERHUB_USERNAME }}
37-
password: ${{ secrets.DOCKERHUB_TOKEN }}
20+
uses: actions/checkout@v5
3821

3922
- name: Login to Github Packages
40-
uses: docker/login-action@v1
23+
uses: docker/login-action@v3
4124
with:
4225
registry: ghcr.io
4326
username: ${{ github.repository_owner }}
4427
password: ${{ secrets.GITHUB_TOKEN }}
4528

46-
- name: Build image and push to Docker Hub and GitHub Container Registry
47-
uses: docker/build-push-action@v2
29+
30+
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
31+
with:
32+
go-version-file: "go.mod"
33+
cache: false
34+
35+
36+
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
4837
with:
49-
context: .
50-
file: ./Dockerfile
51-
platforms: linux/amd64,linux/arm64
52-
tags: ${{ steps.meta.outputs.tags }}
53-
labels: ${{ steps.meta.outputs.labels }}
54-
push: true
55-
56-
- name: Image digest
57-
run: echo ${{ steps.docker_build.outputs.digest }}
58-
38+
version: v0.18.0
39+
- name: Build and push
40+
id: publish-image
41+
env:
42+
IMAGE_VERSION: ${{ github.ref_name }}
43+
KO_DOCKER_REPO: "ghcr.io/${{ github.repository }}"
44+
run: |
45+
ko build . --sbom=none --image-refs ./image-digest --bare --platform linux/arm64,linux/amd64 -t ${IMAGE_VERSION} \
46+
--image-label org.opencontainers.image.title=cloudflare-exporter \
47+
--image-label org.opencontainers.image.description="Prometheus CloudFlare Exporter" \
48+
--image-label org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} \
49+
--image-label org.opencontainers.image.revision=${{ github.sha }} \
50+
--image-label org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} \
51+
--image-label org.opencontainers.image.licenses=Apache-2.0 \
52+
--image-label org.opencontainers.image.version=${IMAGE_VERSION} \
53+
--image-label org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
54+
55+
# Extract image digest from ko output
56+
# The file contains multiple lines (one per platform + manifest list at the end)
57+
# We need only the last line (manifest list) for attestation
58+
cat ./image-digest
59+
IMAGE_REF=$(head -n 1 ./image-digest)
60+
IMAGE_DIGEST=$(echo "$IMAGE_REF" | cut -d'@' -f2)
61+
62+
echo "Image reference: $IMAGE_REF"
63+
echo "Image digest: $IMAGE_DIGEST"
64+
65+
echo "digest=$IMAGE_DIGEST" >> "$GITHUB_OUTPUT"
66+
echo "image-ref=$IMAGE_REF" >> "$GITHUB_OUTPUT"
67+
68+
- name: Attest
69+
uses: actions/attest-build-provenance@v3
70+
id: attest
71+
with:
72+
subject-name: ghcr.io/${{ github.repository }}
73+
subject-digest: ${{ steps.publish-image.outputs.digest }}
74+
push-to-registry: true
75+
76+
distribute-to-dockerhub:
77+
runs-on: ubuntu-latest
78+
needs:
79+
- build-and-push-docker-image
80+
permissions:
81+
packages: read
82+
steps:
83+
- name: Copy image to dockerhub
84+
env:
85+
IMAGE_VERSION: ${{ github.ref_name }}
86+
GHCR_REPO: "ghcr.io/${{ github.repository }}"
87+
GHCR_USERNAME: ${{ github.actor }}
88+
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
89+
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
90+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
91+
run: |
92+
docker run --rm quay.io/containers/skopeo:v1.18.0 \
93+
copy --multi-arch all \
94+
--src-creds "$GHCR_USERNAME:$GHCR_PASSWORD" \
95+
--dest-creds "$DOCKER_USERNAME:$DOCKER_TOKEN" \
96+
docker://${GHCR_REPO}:${IMAGE_VERSION} \
97+
docker://lablabs/cloudflare_exporter:${IMAGE_VERSION}

.github/workflows/go-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout the repository
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v5
1313
- name: Generate build files
1414
uses: thatisuday/go-cross-build@v1
1515
with:
@@ -23,4 +23,4 @@ jobs:
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525
with:
26-
args: "./dist/*"
26+
args: "./dist/*"

.github/workflows/golangci-lint.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ jobs:
1010
name: GO lang CI linter
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v5
14+
- uses: actions/setup-go@v6
15+
with:
16+
go-version: "1.25"
1417
- name: golangci-lint
15-
uses: golangci/golangci-lint-action@v2 # https://github.com/marketplace/actions/run-golangci-lint
18+
uses: golangci/golangci-lint-action@v8 # https://github.com/marketplace/actions/run-golangci-lint
1619
with:
17-
version: v1.43
20+
version: latest

.github/workflows/lint-test.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@v5
1111
with:
1212
fetch-depth: 0
1313

1414
- name: Set up Helm
15-
uses: azure/setup-helm@v1
15+
uses: azure/setup-helm@v4
1616
with:
1717
version: v3.4.0
1818

19-
- uses: actions/setup-python@v2
19+
- uses: actions/setup-python@v6
2020
with:
21-
python-version: 3.7
21+
python-version: 3.8
2222

2323
- name: Set up chart-testing
24-
uses: helm/chart-testing-action@v2.0.1
24+
uses: helm/chart-testing-action@v2.7.0
2525

2626
- name: Run chart-testing (list-changed)
2727
id: list-changed
@@ -35,7 +35,7 @@ jobs:
3535
run: ct lint --target-branch master
3636

3737
- name: Create kind cluster
38-
uses: helm/kind-action@v1.2.0
38+
uses: helm/kind-action@v1.12.0
3939
if: steps.list-changed.outputs.changed == 'true'
4040

4141
- name: Run chart-testing (install)

0 commit comments

Comments
 (0)