Skip to content

Commit e0517de

Browse files
committed
Initial commit
0 parents  commit e0517de

File tree

3 files changed

+208
-0
lines changed

3 files changed

+208
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and Push Cloudsmith Datadog Agent on New Tag
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
workflow_dispatch:
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
check-tags-and-build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout this repo
18+
uses: actions/checkout@v3
19+
20+
- name: Fetch latest upstream tag
21+
run: |
22+
git ls-remote --tags https://github.com/DataDog/integrations-extras.git | \
23+
grep "refs/tags/cloudsmith-" | \
24+
sed 's/.*\///' | \
25+
grep -v '\^{}' | \
26+
sort -V | \
27+
tail -n 1 > latest-tag.txt
28+
29+
cat latest-tag.txt
30+
LATEST_TAG=$(cat latest-tag.txt)
31+
32+
if [ -z "$LATEST_TAG" ]; then
33+
echo "ERROR: No valid upstream tag found!"
34+
exit 1
35+
fi
36+
37+
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
38+
39+
# Extract version number (strip prefix)
40+
IMAGE_VERSION=$(echo "$LATEST_TAG" | sed 's/cloudsmith-//')
41+
42+
if [ -z "$IMAGE_VERSION" ]; then
43+
echo "ERROR: Could not extract IMAGE_VERSION!"
44+
exit 1
45+
fi
46+
47+
echo "IMAGE_VERSION=$IMAGE_VERSION" >> $GITHUB_ENV
48+
49+
- name: Compare with last built version
50+
run: |
51+
LAST_VERSION_FILE=".last-built-version"
52+
LAST_VERSION=$(cat $LAST_VERSION_FILE || echo "none")
53+
echo "Last built: $LAST_VERSION"
54+
echo "Latest tag: ${{ env.LATEST_TAG }} → IMAGE_VERSION=${{ env.IMAGE_VERSION }}"
55+
56+
if [[ "$LAST_VERSION" != "${{ env.LATEST_TAG }}" ]]; then
57+
echo "build_needed=true" >> $GITHUB_ENV
58+
else
59+
echo "build_needed=false" >> $GITHUB_ENV
60+
fi
61+
62+
63+
- name: Install and authenticate Cloudsmith CLI
64+
uses: cloudsmith-io/[email protected]
65+
with:
66+
oidc-namespace: ${{ vars.CLOUDSMITH_NAMESPACE }}
67+
oidc-service-slug: ${{ vars.CLOUDSMITH_SVC_SLUG }}
68+
69+
- name: Build and push image
70+
if: env.build_needed == 'true'
71+
run: |
72+
echo "Building image with tag: ${{ env.IMAGE_VERSION }}"
73+
74+
docker build --build-arg CLOUDSMITH_CLI_VERSION=${{ env.IMAGE_VERSION }} -t docker.cloudsmith.io/${{ vars.CLOUDSMITH_NAMESPACE }}/cloudsmith-datadog-agent/cloudsmith-datadog-agent:${{ env.IMAGE_VERSION }} .
75+
echo "${CLOUDSMITH_API_KEY}" | docker login docker.cloudsmith.io -u ${{ vars.CLOUDSMITH_SVC_SLUG }} --password-stdin
76+
docker push docker.cloudsmith.io/${{ vars.CLOUDSMITH_NAMESPACE }}/cloudsmith-datadog-agent/cloudsmith-datadog-agent:${{ env.IMAGE_VERSION }}
77+
78+
echo "${{ env.LATEST_TAG }}" > .last-built-version
79+
git config user.name "github-actions[bot]"
80+
git config user.email "github-actions[bot]@users.noreply.github.com"
81+
git add .last-built-version
82+
git commit -m "Record built version ${{ env.LATEST_TAG }}"
83+
git push

.gitignore

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# We don't want this to get too large,
2+
# so don't put anything in here that's not either
3+
# specific to this project or a common problem
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
*.jar*
10+
11+
# C extensions
12+
*.so
13+
14+
# Distribution / packaging
15+
.Python
16+
venv/
17+
embedded/
18+
/env/
19+
build/
20+
develop-eggs/
21+
dist/
22+
downloads/
23+
eggs/
24+
.eggs/
25+
lib/
26+
lib64/
27+
parts/
28+
sdist/
29+
var/
30+
*.egg-info/
31+
.installed.cfg
32+
*.egg
33+
*.zip
34+
# PyInstaller
35+
# Usually these files are written by a python script from a template
36+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
37+
*.manifest
38+
*.spec
39+
40+
# Installer logs
41+
pip-log.txt
42+
pip-delete-this-directory.txt
43+
44+
# Unit test / coverage reports
45+
htmlcov/
46+
.tox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
.benchmarks/
56+
57+
# Junit
58+
**/.junit/**
59+
60+
# Translations
61+
*.mo
62+
*.pot
63+
64+
# Django stuff:
65+
*.log
66+
67+
# Sphinx documentation
68+
docs/_build/
69+
70+
# PyBuilder
71+
target/
72+
73+
#Ipython Notebook
74+
.ipynb_checkpoints
75+
76+
#sdk collateral
77+
venv/
78+
embedded/
79+
.bundle/
80+
.ropeproject/
81+
setuptools-*.zip
82+
83+
tmp
84+
# redis tmp config
85+
*.tmp
86+
*.tmp.conf
87+
88+
# OS Specific
89+
*.DS_Store
90+
*.fuse_hidden*
91+
92+
# Vi(m) stuff
93+
*.swp
94+
95+
# Rbenv stuff
96+
.rbenv-gemsets
97+
.ruby-version
98+
99+
# Common IDEs & editors
100+
.idea/
101+
.vscode/
102+
*.iml
103+
104+
# wheels
105+
wheelhouse/
106+
*.whl
107+
108+
.pytest_cache
109+
110+
# Type checking
111+
.mypy_cache
112+
113+
# by default, ignore in-toto metadata from the command line
114+
.links/
115+
*.link
116+
117+
## Kind
118+
.kube
119+
120+
# pyenv versioning
121+
.python-version

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM public.ecr.aws/datadog/agent:7
2+
ARG INTEGRATION_VERSION
3+
RUN agent integration install -r -t datadog-cloudsmith==${INTEGRATION_VERSION}
4+
CMD ["agent", "run"]

0 commit comments

Comments
 (0)