Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing the Drone to GitHub Actions migration #2749

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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
163 changes: 86 additions & 77 deletions .github/workflows/publish-alloy-devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
pull_request:

permissions:
contents: read
Expand Down Expand Up @@ -30,14 +31,22 @@ jobs:
go-version-file: go.mod
cache: false

- name: Log Paulin
run: |
git status -s

- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/dockerhub-login@dockerhub-login-v1.0.1

- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch-alloy-alloy-devel-${GITHUB_SHA} --driver docker-container --use
./tools/ci/docker-containers alloy-devel
docker buildx rm multiarch-alloy-alloy-devel-${GITHUB_SHA}
- name: Log Paulin
run: |
git status -s

# - run: |
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# docker buildx create --name multiarch-alloy-alloy-devel-${GITHUB_SHA} --driver docker-container --use
# ./tools/ci/docker-containers alloy-devel
# docker buildx rm multiarch-alloy-alloy-devel-${GITHUB_SHA}

publish_linux_boringcrypto_container:
name: Publish Linux alloy-devel-boringcrypto container
Expand All @@ -63,75 +72,75 @@ jobs:
- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/dockerhub-login@dockerhub-login-v1.0.1

- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch-alloy-alloy-devel-boringcrypto-${GITHUB_SHA} --driver docker-container --use
./tools/ci/docker-containers alloy-devel-boringcrypto
docker buildx rm multiarch-alloy-alloy-devel-boringcrypto-${GITHUB_SHA}

update_deployment_tools:
name: Update deployment_tools
runs-on: ubuntu-latest
needs:
- publish_linux_container
- publish_linux_boringcrypto_container
steps:

- name: Log in to Google Artifact Registry
# This step needs to run before "Checkout code".
# That's because the login to GAR generates a new file.
# We don't want this file to end up in the repo directory.
# Then "tools/image-tag" would get confused because "git status" no longer reports a clean repo.
# TODO: Ask the platform team to rework the login to GAR to not generate such files?
uses: grafana/shared-workflows/actions/login-to-gar@main
with:
registry: "us-docker.pkg.dev"
environment: "prod"

- name: Get Vault secrets
uses: grafana/shared-workflows/actions/get-vault-secrets@main
with:
common_secrets: |
GITHUB_APP_ID=updater-app:app-id
GITHUB_APP_INSTALLATION_ID=updater-app:app-installation-id
GITHUB_APP_PRIVATE_KEY=updater-app:private-key

- name: Checkout code
uses: actions/checkout@v4

- name: Get the image tag
run: |
echo "$(bash ./tools/image-tag-docker)" > .tag-only
echo "grafana/alloy-dev:$(bash ./tools/image-tag-docker)" > .image-tag

- name: Update to latest image
run: |
set -e -o pipefail

echo "The image tag is: $(cat .image-tag)"

cat << EOF > config.json
{
"git_committer_name": "updater-for-ci[bot]",
"git_author_name": "updater-for-ci[bot]",
"git_committer_email": "119986603+updater-for-ci[bot]@users.noreply.github.com",
"git_author_email": "119986603+updater-for-ci[bot]@users.noreply.github.com",
"destination_branch": "master",
"repo_name": "deployment_tools",
"update_jsonnet_attribute_configs": [
{
"file_path": "ksonnet/lib/alloy/waves/alloy.libsonnet",
"jsonnet_key": "dev_canary",
"jsonnet_value_file": ".image-tag"
}
]
}
EOF

docker run --rm \
-e GITHUB_APP_ID \
-e GITHUB_APP_INSTALLATION_ID \
-e GITHUB_APP_PRIVATE_KEY \
-e CONFIG_JSON="$(cat config.json)" \
-v ./.image-tag:/app/.image-tag \
us-docker.pkg.dev/grafanalabs-global/docker-deployment-tools-prod/updater |& tee updater-output.log
# - run: |
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# docker buildx create --name multiarch-alloy-alloy-devel-boringcrypto-${GITHUB_SHA} --driver docker-container --use
# ./tools/ci/docker-containers alloy-devel-boringcrypto
# docker buildx rm multiarch-alloy-alloy-devel-boringcrypto-${GITHUB_SHA}

# update_deployment_tools:
# name: Update deployment_tools
# runs-on: ubuntu-latest
# needs:
# - publish_linux_container
# - publish_linux_boringcrypto_container
# steps:

# - name: Log in to Google Artifact Registry
# # This step needs to run before "Checkout code".
# # That's because the login to GAR generates a new file.
# # We don't want this file to end up in the repo directory.
# # Then "tools/image-tag" would get confused because "git status" no longer reports a clean repo.
# # TODO: Ask the platform team to rework the login to GAR to not generate such files?
# uses: grafana/shared-workflows/actions/login-to-gar@main
# with:
# registry: "us-docker.pkg.dev"
# environment: "prod"

# - name: Get Vault secrets
# uses: grafana/shared-workflows/actions/get-vault-secrets@main
# with:
# common_secrets: |
# GITHUB_APP_ID=updater-app:app-id
# GITHUB_APP_INSTALLATION_ID=updater-app:app-installation-id
# GITHUB_APP_PRIVATE_KEY=updater-app:private-key

# - name: Checkout code
# uses: actions/checkout@v4

# - name: Get the image tag
# run: |
# echo "$(bash ./tools/image-tag-docker)" > .tag-only
# echo "grafana/alloy-dev:$(bash ./tools/image-tag-docker)" > .image-tag

# - name: Update to latest image
# run: |
# set -e -o pipefail

# echo "The image tag is: $(cat .image-tag)"

# cat << EOF > config.json
# {
# "git_committer_name": "updater-for-ci[bot]",
# "git_author_name": "updater-for-ci[bot]",
# "git_committer_email": "119986603+updater-for-ci[bot]@users.noreply.github.com",
# "git_author_email": "119986603+updater-for-ci[bot]@users.noreply.github.com",
# "destination_branch": "master",
# "repo_name": "deployment_tools",
# "update_jsonnet_attribute_configs": [
# {
# "file_path": "ksonnet/lib/alloy/waves/alloy.libsonnet",
# "jsonnet_key": "dev_canary",
# "jsonnet_value_file": ".image-tag"
# }
# ]
# }
# EOF

# docker run --rm \
# -e GITHUB_APP_ID \
# -e GITHUB_APP_INSTALLATION_ID \
# -e GITHUB_APP_PRIVATE_KEY \
# -e CONFIG_JSON="$(cat config.json)" \
# -v ./.image-tag:/app/.image-tag \
# us-docker.pkg.dev/grafanalabs-global/docker-deployment-tools-prod/updater |& tee updater-output.log
4 changes: 2 additions & 2 deletions tools/ci/docker-containers
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ set -euxo pipefail
export TARGET_CONTAINER=${1:-}
export DRONE_TAG=${DRONE_TAG:-}

export RELEASE_ALLOY_IMAGE=grafana/alloy
export DEVEL_ALLOY_IMAGE=grafana/alloy-dev
export RELEASE_ALLOY_IMAGE=ptodev/alloy
export DEVEL_ALLOY_IMAGE=ptodev/alloy-dev

# We need to determine what version to assign to built binaries. If containers
# are being built from a Drone tag trigger, we force the version to come from the
Expand Down
Loading