Skip to content

Commit

Permalink
Taskgraph follow-up fixes (#162)
Browse files Browse the repository at this point in the history
* Fix issues in .taskcluster.yml

Raise level to 3 when appropriate to match ci-config; build for master/dev/production.

* Fix some bugs in push_images.sh

I missed a few things here:
* Fix secret parsing
* Create archive tag in addition to branch tag
* We need the version to create the archive tag properly
* Typo (GIT_HEAD_REV vs VCS_HEAD_REV)
  • Loading branch information
bhearsum authored May 2, 2024
1 parent 2ccf81d commit 43349ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 7 additions & 3 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ policy:
tasks:
- $let:
trustDomain: "releng"
level: "1"
level: "3"
ownerEmail:
$switch:
'tasks_for == "github-push"': '${event.pusher.email}'
Expand Down Expand Up @@ -83,10 +83,14 @@ tasks:
$eval: 'tasks_for[:19] == "github-pull-request"'
in:
$let:
level:
$if: 'tasks_for in ["github-release", "github-push", "cron", "action"] && repoUrl == "https://github.com/mozilla-releng/k8s-autoscale"'
then: 3
else: 1
short_base_ref:
$switch:
'base_ref[:10] == "refs/tags/"': '${base_ref[10:]}'
'base_ref[:11] == "refs/heads/"': '${$base_ref[11:]}'
'base_ref[:11] == "refs/heads/"': '${base_ref[11:]}'
$default: '${base_ref}'
short_head_ref:
$switch:
Expand All @@ -96,7 +100,7 @@ tasks:
in:
$if: >
tasks_for in ["action", "pr-action", "cron"]
|| (tasks_for == "github-push" && short_head_ref == "main")
|| (tasks_for == "github-push" && (short_head_ref in ["master", "dev", "production"]))
|| (isPullRequest && pullRequestAction in ["opened", "reopened", "synchronize"])
then:
taskId: {$if: 'tasks_for != "action" && tasks_for != "pr-action"', then: '${ownTaskId}'}
Expand Down
2 changes: 2 additions & 0 deletions taskcluster/docker/skopeo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RUN ["/usr/local/go/bin/go", "build", \
FROM debian:buster

# %include-run-task
# %include version.txt
COPY topsrcdir/version.txt /version.txt

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
Expand Down
9 changes: 7 additions & 2 deletions taskcluster/docker/skopeo/push_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -e

export
test $DOCKER_REPO
test $DOCKER_TAG
test $MOZ_FETCHES_DIR
test $SECRET_URL
test $TASKCLUSTER_ROOT_URL
Expand Down Expand Up @@ -35,12 +36,16 @@ then
else
echo "=== Generating dockercfg ==="
install -m 600 /dev/null $HOME/.dockercfg
curl $SECRET_URL | jq '.secret.dockercfg' > $HOME/.dockercfg
curl $SECRET_URL | jq '.secret.docker.dockercfg' > $HOME/.dockercfg

echo "=== Pushing to docker hub ==="
DOCKER_TAG="${DOCKER_TAG}-$(cat ./version.txt)-$(date +%Y%m%d%H%M%S)-${GIT_HEAD_REV}"
APP_VERSION="$(cat /version.txt)"
DOCKER_TAG="$(echo ${DOCKER_TAG} | cut -f3 -d/)"
DOCKER_ARCHIVE_TAG="${DOCKER_TAG}-${APP_VERSION}-$(date +%Y%m%d%H%M%S)-${VCS_HEAD_REV}"
skopeo copy oci:k8s_autoscale:final docker://$DOCKER_REPO:$DOCKER_TAG
skopeo inspect docker://$DOCKER_REPO:$DOCKER_TAG
skopeo copy oci:k8s_autoscale:final docker://$DOCKER_REPO:$DOCKER_ARCHIVE_TAG
skopeo inspect docker://$DOCKER_REPO:$DOCKER_ARCHIVE_TAG
fi

echo "=== Clean up ==="
Expand Down

1 comment on commit 43349ff

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

TemplateError at template.tasks[0]["base_ref"]: $switch can only have one truthy condition

Please sign in to comment.