-
Notifications
You must be signed in to change notification settings - Fork 3
43 lines (42 loc) · 1.71 KB
/
publish-docker-image-to-dockerhub.yaml
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
name: Publish docker image to DockerHub
on:
release:
types:
- published
env:
ECR_REPOSITORY: pos-network-node
DOCKERHUB_REPOSITORY: cerebellumnetwork
PACKAGE_NAME: pos-node
jobs:
tag-and-push:
runs-on: [self-hosted, cere-network-xlarge]
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEV_NETWORK_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_NETWORK_AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Pull image from ECR and change name, push tagged version to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA
docker image tag $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA $DOCKERHUB_REPOSITORY/$PACKAGE_NAME:${GITHUB_REF##*/}
docker image tag $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_REF##*/}
docker image tag $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA $DOCKERHUB_REPOSITORY/$PACKAGE_NAME:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_REF##*/}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish image to DockerHub
id: docker_publish
run: |
docker push -a $DOCKERHUB_REPOSITORY/$PACKAGE_NAME
- name: Image digest
run: echo ${{ steps.docker_publish.outputs.digest }}