Replace Docker Hub with Aliyun repositories #133
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
paths: | |
- 'scripts/**' | |
- 'Dockerfile-for-github-action' | |
- 'requirements.txt' | |
- 'example.env' | |
- '.github/workflows/docker-image.yml' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log into docker hub registry | |
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
- name: Build and push Docker image | |
run: | | |
PLATFORMS=linux/arm64,linux/amd64 | |
DOCKER_IMAGE=arcw/sgcc_electricity | |
docker buildx build --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:1.4.0 --file Dockerfile-for-github-action --push . | |
- name: pull Docker image | |
run: | | |
docker pull mongo:4.4.18 | |
docker tag mongo:4.4.18 registry.cn-hangzhou.aliyuncs.com/arcw/mongo:4.4.18 | |
- name: Log into Aliyun hub registry and push Docker image | |
run: | | |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.ALIYUN_USERNAME }} --password-stdin registry.cn-hangzhou.aliyuncs.com | |
PLATFORMS=linux/arm64,linux/amd64 | |
DOCKER_IMAGE=registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity | |
docker buildx build --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:1.4.0 --file Dockerfile-for-github-action --push . | |
docker push registry.cn-hangzhou.aliyuncs.com/arcw/mongo:4.4.18 |