File tree 2 files changed +49
-3
lines changed
2 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,12 @@ permissions:
15
15
contents : read
16
16
deployments : none
17
17
issues : none
18
- packages : none
19
18
pull-requests : none
20
19
repository-projects : none
21
20
security-events : none
22
21
statuses : none
22
+ # Necessary to push docker images to ghcr.io.
23
+ packages : write
23
24
24
25
# Cancel in-progress runs for pull requests when developers push
25
26
# additional changes
67
68
68
69
- name : Check format
69
70
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
41
41
docker buildx create --use --platform=linux/arm64,linux/amd64,linux/arm/v7 --name $BUILDER_NAME
42
42
else
43
43
echo " Builder $BUILDER_NAME already exists. Using it."
44
- docker buildx use $BUILDER_NAME
45
44
fi
46
45
47
46
# Ensure the builder is bootstrapped and ready to use
63
62
args+=( --load )
64
63
fi
65
64
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 .
67
66
68
67
# Check if archs contains the current. If so, then output a message!
69
68
if [[ -z " ${CI:- } " ]] && [[ " ${archs[@]} " =~ " ${current} " ]]; then
You can’t perform that action at this time.
0 commit comments