Skip to content
aliyun

GitHub Action

Alibaba Cloud Container Registry (ACR) Login

v1 Latest version
Use latest version
aliyun

Alibaba Cloud Container Registry (ACR) Login

Log in to a container registry

Installation

Copy and paste the following snippet into your .yml file.

- name: Alibaba Cloud Container Registry (ACR) Login
  uses: aliyun/[email protected]
Learn more about this action in aliyun/acr-login
Choose a version

Log in to a container registry

Use this GitHub Action to log in to a private container registry of Alibaba Cloud Container Registry. Once login is done, the next set of actions in the workflow can perform tasks such as building, tagging and pushing containers.

- uses: aliyun/[email protected]
  with:
    login-server: '<login server>' # default: https://index.docker.io/v1/
    username: '<username>'
    password: '<password>'

Or

- uses: aliyun/[email protected]
  with:
    region-id: '<region id>' # example: cn-hangzhou
    access-key-id: '<access key id>'
    access-key-secret: '<access key secret>'

Or

- uses: aliyun/[email protected]
  with:
    login-server: '<login server>' # example: https://my-test-registry.cn-hangzhou.cr.aliyuncs.com
    region-id: '<region id>' # example: cn-hangzhou
    access-key-id: '<access key id>'
    access-key-secret: '<access key secret>'
    instance-id: '<registry instance id>'

Refer to the action metadata file for details about all the inputs: action.yml

You can build and push container registry by using the following example

- name: Login to ACR
  uses: aliyun/[email protected]
  with:
    login-server: https://registry.cn-hangzhou.aliyuncs.com
    username: "${{ secrets.REGISTRY_USERNAME }}"
    password: "${{ secrets.REGISTRY_PASSWORD }}"
- name: Build and push image
  env:
    IMAGE_TAG: ${{ github.sha }}
  run: |
    docker build -t registry.cn-hangzhou.aliyuncs.com/myrepo/demo:$IMAGE_TAG .
    docker push registry.cn-hangzhou.aliyuncs.com/myrepo/demo:$IMAGE_TAG

Prerequisite

Get the username and password of your container registry or get the authentication token fo temporary access by access key.

Now add the username and password or access key as secrets in the GitHub repository.