Skip to content

Commit f760062

Browse files
committed
use docker login
1 parent 81154da commit f760062

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

.github/workflows/chicmoz-prod.yml

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: CI/CD Chicmoz Prod
2-
# TODO
32

43
on:
54
push:
@@ -11,11 +10,12 @@ on:
1110
types:
1211
- closed
1312

13+
env:
14+
DOCKER_CONFIG: ${{ github.workspace }}/.docker
15+
1416
jobs:
1517
build_and_deploy:
16-
runs-on:
17-
labels: ubuntu-latest
18-
18+
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout Repository
2121
uses: actions/checkout@v2
@@ -31,13 +31,10 @@ jobs:
3131
with:
3232
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
3333

34-
- name: Log in to DigitalOcean Container Registry with short-lived credentials
35-
run: doctl registry login --expiry-seconds 1800
36-
37-
- name: Cleanup old images
34+
- name: Set up Docker authentication
3835
run: |
39-
chmod +x ".github/workflows/cleanup-script.sh"
40-
bash -x ".github/workflows/cleanup-script.sh"
36+
mkdir -p ${{ env.DOCKER_CONFIG }}
37+
echo '{"auths":{"registry.digitalocean.com":{"auth":"'$(echo -n ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | base64)'"}}}' > ${{ env.DOCKER_CONFIG }}/config.json
4138
4239
- name: Build and Push Images
4340
run: |
@@ -46,7 +43,7 @@ jobs:
4643
4744
build_and_push() {
4845
for i in $(seq 1 $MAX_RETRIES); do
49-
if skaffold build --filename "k8s/production/skaffold.production.yaml"; then
46+
if DOCKER_CONFIG=${{ env.DOCKER_CONFIG }} skaffold build --filename "k8s/production/skaffold.production.yaml" --default-repo=registry.digitalocean.com/aztlan-containers; then
5047
return 0
5148
fi
5249
echo "Attempt $i failed. Retrying in $RETRY_DELAY seconds..."
@@ -62,6 +59,11 @@ jobs:
6259
exit 1
6360
fi
6461
62+
- name: Cleanup old images
63+
run: |
64+
chmod +x "./cleanup-script.sh"
65+
./cleanup-script.sh
66+
6567
- name: Save DigitalOcean kubeconfig
6668
run: doctl kubernetes cluster kubeconfig save "chicmoz-prod"
6769

@@ -71,12 +73,12 @@ jobs:
7173
RETRY_DELAY=10
7274
7375
for i in $(seq 1 $MAX_RETRIES); do
74-
if skaffold run --filename "k8s/production/skaffold.production.yaml"; then
76+
if DOCKER_CONFIG=${{ env.DOCKER_CONFIG }} skaffold run --filename "k8s/production/skaffold.production.yaml" --default-repo=registry.digitalocean.com/aztlan-containers; then
7577
echo "Deployment successful"
7678
exit 0
7779
fi
7880
echo "Attempt $i failed. Retrying in $RETRY_DELAY seconds..."
79-
sleep $RETRY_DELAY
81+
sleep $RETRY_DELAY
8082
done
8183
8284
echo "Deployment failed after $MAX_RETRIES attempts"

0 commit comments

Comments
 (0)