forked from amaysim-au/docker-serverless
-
Notifications
You must be signed in to change notification settings - Fork 1
128 lines (124 loc) · 4.26 KB
/
registry.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Build and Push Docker image
on:
push:
tags:
- '*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and export
uses: docker/build-push-action@v2
with:
context: .
tags: dnxsolutions/serverless:latest
outputs: type=docker,dest=/tmp/serverless.tar
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: serverless
path: /tmp/serverless.tar
ecr:
name: Push to ECR
runs-on: ubuntu-latest
needs: build
container: dnxsolutions/aws:2.1.6-dnx1
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Get the tag
id: get_tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Download docker artifact
uses: actions/download-artifact@v2
with:
name: serverless
path: /tmp
- name: Load, tag, and push image
env:
ECR_REGISTRY: public.ecr.aws
ECR_REPOSITORY: dnxsolutions/serverless
IMAGE_TAG: ${{ steps.get_tag.outputs.tag }}
run: |
apk add docker
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
docker load --input /tmp/serverless.tar
docker image ls -a
docker tag $ECR_REPOSITORY:latest $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker tag $ECR_REPOSITORY:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker-hub:
name: Push to Docker Hub
runs-on: ubuntu-latest
needs: build
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DNX_DOCKERHUB_USERNAME }}
password: ${{ secrets.DNX_DOCKERHUB_TOKEN }}
- name: Get the tag
id: get_tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: serverless
path: /tmp
- name: Load, tag, and push image
env:
DOCKERHUB_REPOSITORY: dnxsolutions/serverless
IMAGE_TAG: ${{ steps.get_tag.outputs.tag }}
run: |
docker load --input /tmp/serverless.tar
docker image ls -a
docker push $DOCKERHUB_REPOSITORY:latest
docker tag $DOCKERHUB_REPOSITORY:latest $DOCKERHUB_REPOSITORY:$IMAGE_TAG
docker push $DOCKERHUB_REPOSITORY:$IMAGE_TAG
ghcr:
name: Push to GitHub Registry
runs-on: ubuntu-latest
needs: build
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get the tag
id: get_tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: serverless
path: /tmp
- name: Load, tag, and push image
env:
BASE_REPOSITORY: dnxsolutions/serverless
GHCR_REPOSITORY: ghcr.io/dnxlabs/serverless
IMAGE_TAG: ${{ steps.get_tag.outputs.tag }}
run: |
docker load --input /tmp/serverless.tar
docker image ls -a
docker tag $BASE_REPOSITORY:latest $GHCR_REPOSITORY:latest
docker push $GHCR_REPOSITORY:latest
docker tag $GHCR_REPOSITORY:latest $GHCR_REPOSITORY:$IMAGE_TAG
docker push $GHCR_REPOSITORY:$IMAGE_TAG