File tree Expand file tree Collapse file tree 2 files changed +49
-3
lines changed
Expand file tree Collapse file tree 2 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,12 @@ permissions:
1515 contents : read
1616 deployments : none
1717 issues : none
18- packages : none
1918 pull-requests : none
2019 repository-projects : none
2120 security-events : none
2221 statuses : none
22+ # Necessary to push docker images to ghcr.io.
23+ packages : write
2324
2425# Cancel in-progress runs for pull requests when developers push
2526# additional changes
6768
6869 - name : Check format
6970 run : ./scripts/check_fmt.sh
71+ build :
72+ runs-on : ubuntu-latest
73+ steps :
74+ - name : Checkout
75+ uses : actions/checkout@v4
76+ with :
77+ # Needed to get older tags
78+ fetch-depth : 0
79+
80+ - uses : actions/setup-go@v5
81+ with :
82+ go-version : " ~1.22"
83+
84+ - name : Login to GitHub Container Registry
85+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
86+ uses : docker/login-action@v2
87+ with :
88+ registry : ghcr.io
89+ username : ${{ github.actor }}
90+ password : ${{ secrets.GITHUB_TOKEN }}
91+
92+ # do not push images for pull requests
93+ - name : Build
94+ if : github.event_name == 'pull_request'
95+ run : |
96+ VERSION=$(./scripts/version.sh)-dev-$(git rev-parse --short HEAD)
97+ BASE=ghcr.io/coder/envbuilder-preview
98+
99+ ./scripts/build.sh \
100+ --arch=amd64 \
101+ --base=$BASE \
102+ --tag=$VERSION
103+
104+ - name : Build and Push
105+ if : github.ref == 'refs/heads/main'
106+ run : |
107+ VERSION=$(./scripts/version.sh)-dev-$(git rev-parse --short HEAD)
108+ BASE=ghcr.io/coder/envbuilder-preview
109+
110+ ./scripts/build.sh \
111+ --arch=amd64 \
112+ --arch=arm64 \
113+ --arch=arm \
114+ --base=$BASE \
115+ --tag=$VERSION \
116+ --push
Original file line number Diff line number Diff line change @@ -41,7 +41,6 @@ if [ -z "$BUILDER_EXISTS" ]; then
4141 docker buildx create --use --platform=linux/arm64,linux/amd64,linux/arm/v7 --name $BUILDER_NAME
4242else
4343 echo " Builder $BUILDER_NAME already exists. Using it."
44- docker buildx use $BUILDER_NAME
4544fi
4645
4746# Ensure the builder is bootstrapped and ready to use
6362 args+=( --load )
6463fi
6564
66- docker buildx build " ${args[@]} " -t $base :$tag -t $base :latest -f Dockerfile .
65+ docker buildx build --builder $BUILDER_NAME " ${args[@]} " -t $base :$tag -t $base :latest -f Dockerfile .
6766
6867# Check if archs contains the current. If so, then output a message!
6968if [[ -z " ${CI:- } " ]] && [[ " ${archs[@]} " =~ " ${current} " ]]; then
You can’t perform that action at this time.
0 commit comments