Skip to content

Commit 94c80e4

Browse files
author
Akash Satheesan
committed
fix(ci): build+push image in release flow
1 parent 7b8cd25 commit 94c80e4

File tree

6 files changed

+59
-151
lines changed

6 files changed

+59
-151
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -402,73 +402,6 @@ jobs:
402402
- name: Remove release packages and test artifacts
403403
run: rm -rf ./release-packages ./test/test-results
404404

405-
# Builds both amd64 and arm64 images
406-
docker-images:
407-
runs-on: ubuntu-latest
408-
needs: [package-linux-amd64, package-linux-arm64]
409-
steps:
410-
- uses: actions/checkout@v2
411-
412-
- name: Download release package
413-
uses: actions/download-artifact@v2
414-
with:
415-
name: release-packages
416-
path: ./release-packages
417-
418-
- name: Set up QEMU
419-
uses: docker/setup-qemu-action@v1
420-
421-
- name: Set up Docker Buildx
422-
uses: docker/setup-buildx-action@v1
423-
424-
- name: Run ./ci/steps/build-docker-image.sh
425-
run: ./ci/steps/build-docker-image.sh
426-
427-
- name: Upload release images
428-
uses: actions/upload-artifact@v2
429-
with:
430-
name: release-images
431-
path: ./release-images
432-
433-
trivy-scan-image:
434-
runs-on: ubuntu-20.04
435-
needs: docker-images
436-
# NOTE@jsjoeio: disabling due to a memory issue upstream
437-
# See: https://github.com/github/codeql-action/issues/528
438-
if: 1 == 2
439-
steps:
440-
- name: Checkout code
441-
uses: actions/checkout@v2
442-
443-
- name: Download release images
444-
uses: actions/download-artifact@v2
445-
with:
446-
name: release-images
447-
path: ./release-images
448-
449-
- name: Run Trivy vulnerability scanner in image mode
450-
# Commit SHA for v0.0.17
451-
uses: aquasecurity/trivy-action@ac8de07fd168680dd0331bef43681c0e150e9ad1
452-
with:
453-
input: "./release-images/code-server-amd64-*.tar"
454-
scan-type: "image"
455-
ignore-unfixed: true
456-
format: "template"
457-
template: "@/contrib/sarif.tpl"
458-
output: "trivy-image-results.sarif"
459-
severity: "HIGH,CRITICAL"
460-
461-
- name: Debug Trivy SARIF file
462-
run: cat trivy-image-results.sarif && ls -l trivy-image-results.sarif
463-
464-
- name: Upload Trivy scan results to GitHub Security tab
465-
uses: github/codeql-action/upload-sarif@v1
466-
with:
467-
sarif_file: "trivy-image-results.sarif"
468-
469-
# We have to use two trivy jobs
470-
# because GitHub only allows
471-
# codeql/upload-sarif action per job
472405
trivy-scan-repo:
473406
runs-on: ubuntu-20.04
474407
steps:

.github/workflows/docker.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: docker
2+
3+
on:
4+
# Shows the manual trigger in GitHub UI
5+
# helpful as a back-up in case the GitHub Actions Workflow fails
6+
workflow_dispatch:
7+
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
docker-images:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v1
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v1
22+
23+
- name: Run ./ci/steps/build-docker-image.sh
24+
run: ./ci/steps/build-docker-image.sh
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
28+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/publish.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@ jobs:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2323
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2424

25-
# NOTE: this job requires curl, jq and docker
26-
# All of them are included in ubuntu-latest.
27-
docker:
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v2
31-
32-
- name: Run ./ci/steps/push-docker-manifest.sh
33-
run: ./ci/steps/push-docker-manifest.sh
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
37-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
38-
3925
homebrew:
4026
# The newest version of code-server needs to be available on npm when this runs
4127
# otherwise, it will 404 and won't open a PR to bump version on homebrew/homebrew-core

ci/release-image/docker-bake.hcl

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,11 @@ variable "VERSION" {
77
}
88

99
group "default" {
10-
targets = ["code-server-amd64", "code-server-arm64"]
10+
targets = ["code-server"]
1111
}
1212

13-
target "code-server-amd64" {
13+
target "code-server" {
1414
dockerfile = "ci/release-image/Dockerfile"
15-
tags = ["docker.io/codercom/code-server-amd64:${VERSION}"]
16-
platforms = ["linux/amd64"]
17-
output = ["type=tar,dest=./release-images/code-server-amd64-${VERSION}.tar"]
18-
}
19-
20-
target "code-server-arm64" {
21-
dockerfile = "ci/release-image/Dockerfile"
22-
tags = ["docker.io/codercom/code-server-arm64:${VERSION}"]
23-
platforms = ["linux/arm64"]
24-
output = ["type=tar,dest=./release-images/code-server-arm64-${VERSION}.tar"]
15+
tags = ["docker.io/codercom/code-server:${VERSION}"]
16+
platforms = ["linux/amd64", "linux/arm64"]
2517
}

ci/steps/build-docker-image.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
# See if this version already exists on Docker Hub.
5+
function version_exists() {
6+
local output
7+
output=$(curl --silent "https://index.docker.io/v1/repositories/codercom/code-server/tags/$VERSION")
8+
if [[ $output == "Tag not found" ]]; then
9+
return 1
10+
else
11+
return 0
12+
fi
13+
}
14+
415
main() {
516
cd "$(dirname "$0")/../.."
17+
18+
# ci/lib.sh sets VERSION and provides download_artifact here
619
source ./ci/lib.sh
720

8-
mkdir -p release-images
9-
docker buildx bake -f ci/release-image/docker-bake.hcl
21+
if version_exists; then
22+
echo "$VERSION is already pushed"
23+
return
24+
fi
25+
26+
# Download the release-packages artifact
27+
download_artifact release-packages ./release-packages
28+
29+
# Login to Docker
30+
if [[ ${CI-} ]]; then
31+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
32+
fi
33+
34+
docker buildx bake -f ci/release-image/docker-bake.hcl --push
1035
}
1136

1237
main "$@"

ci/steps/push-docker-manifest.sh

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)