当前位置: 首页 > 软件库 > 云计算 > >

Publish-Docker-Github-Action

授权协议 MIT License
开发语言 Java
所属分类 云计算
软件类型 开源软件
地区 不详
投 递 者 岳意蕴
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Publishes docker containers

Actions StatusActions StatusActions Status

This Action for Docker uses the Git branch as the Docker tag for building and pushing the container.Hereby the master-branch is published as the latest-tag.

Usage

Example pipeline

name: Publish Docker
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Publish to Registry
      uses: elgohr/Publish-Docker-Github-Action@master
      with:
        name: myDocker/repository
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}

Mandatory Arguments

name is the name of the image you would like to push
username the login username for the registry
password the authentication token [preferred] or login password for the registry.

If you would like to publish the image to other registries, these actions might be helpful

Registry Action
Amazon Webservices Elastic Container Registry (ECR) https://github.com/elgohr/ecr-login-action
Google Cloud Container Registry https://github.com/elgohr/gcloud-login-action

Outputs

tag is the tag, which was pushed
snapshot-tag is the tag that is generated by the snapshot-option and pushed
digest is the digest of the image, which was pushed

Optional Arguments

registry

Use registry for pushing to a custom registry.

As GitHub Packages Docker registry uses a different path format to GitHub Container Registry or Docker Hub. See Configuring Docker for use with GitHub Package Registry for more information.
For publishing to GitHub Container Registry please see Migrating to GitHub Container Registry for Docker images.

If you're using GitHub Packages Docker or GitHub Container Registry, you might also want to use ${{ github.actor }} as the username.

with:
  name: owner/repository/image
  username: ${{ github.actor }}
  password: ${{ secrets.GITHUB_TOKEN }}
  registry: ghcr.io

snapshot

Use snapshot to push an additional image, which is tagged with
{YEAR}{MONTH}{DAY}{HOUR}{MINUTE}{SECOND}{first 6 digits of the git sha}.
The date was inserted to prevent new builds with external dependencies override older builds with the same sha.When you would like to think about versioning images, this might be useful.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  snapshot: true

default_branch

Use default_branch when you want to use a different branch than master as the default branch.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  default_branch: trunk

dockerfile

Use dockerfile when you would like to explicitly build a Dockerfile.
This might be useful when you have multiple DockerImages.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  dockerfile: MyDockerFileName

workdir

Use workdir when you would like to change the directory for building.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  workdir: mySubDirectory

context

Use context when you would like to change the Docker build context.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  context: myContextDirectory

buildargs

Use buildargs when you want to pass a list of environment variables as build-args. Identifiers are separated by comma.
All buildargs will be masked, so that they don't appear in the logs.

- name: Publish to Registry
  uses: elgohr/Publish-Docker-Github-Action@master
  env:
    MY_FIRST: variableContent
    MY_SECOND: variableContent
  with:
    name: myDocker/repository
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    buildargs: MY_FIRST,MY_SECOND

buildoptions

Use buildoptions when you want to configure options for building.

- name: Publish to Registry
  uses: elgohr/Publish-Docker-Github-Action@master
  with:
    name: myDocker/repository
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    buildoptions: "--compress --force-rm"

cache

Use cache when you have big images, that you would only like to build partially (changed layers).

CAUTION: Docker builds will cache non-repoducable commands, such as installing packages. If you use this option, your packages will never update. To avoid this, run this action on a schedule with caching disabled to rebuild the cache periodically.

name: Publish to Registry
on:
  push:
    branches:
      - master
  schedule:
    - cron: '0 2 * * 0' # Weekly on Sundays at 02:00
jobs:
  update:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Publish to Registry
      uses: elgohr/Publish-Docker-Github-Action@master
      with:
        name: myDocker/repository
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        cache: ${{ github.event_name != 'schedule' }}

no_push

Use no_push when you want to build an image, but not push it to a registry.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  no_push: ${{ github.event_name == 'push' }}

Tags

This action supports multiple options that tags are handled.
By default a tag is pushed as latest.
Furthermore, one of the following options can be used.

tags

Use tags when you want to bring your own tags (separated by comma).

- name: Publish to Registry
  uses: elgohr/Publish-Docker-Github-Action@master
  with:
    name: myDocker/repository
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    tags: "latest,another"

When using dynamic tag names the environment variable must be set via echo, as variables set in the environment will not auto resolve by convention.
This example illustrates how you would push to latest along with creating a custom version tag in a release. Setting it to only run on published events will keep your tags from being filled with commit hashes and will only publish when a GitHub release is created, so if the GitHub release is 2.14 this will publish to the latest and 2.14 tags.

name: Publish to Registry
on:    
  release:
      types: [published]
  push:
    branches:
      - master
  schedule:
    - cron: '0 2 * * 0' # Weekly on Sundays at 02:00
jobs:
  update:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Publish to Registry
      pre: echo ::save-state name=RELEASE_VERSION::$(echo ${GITHUB_REF:10})
      uses: elgohr/Publish-Docker-Github-Action@master
      with:
        name: myDocker/repository
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        tags: "latest,${{ env.STATE_RELEASE_VERSION }}"

tag_names

Use tag_names when you want to push tags/release by their git name (e.g. refs/tags/MY_TAG_NAME).

CAUTION: Images produced by this feature can be override by branches with the same name - without a way to restore.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  tag_names: true

tag_semver

Use tag_semver when you want to push tags using the semver syntax by their git name (e.g. refs/tags/v1.2.3). This will push fourdocker tags: 1.2.3, 1.2 and 1. A prefix 'v' will automatically be removed.

CAUTION: Images produced by this feature can be override by branches with the same name - without a way to restore.

with:
  name: myDocker/repository
  username: ${{ secrets.DOCKER_USERNAME }}
  password: ${{ secrets.DOCKER_PASSWORD }}
  tag_semver: true
  • GitHub Actions 持续集成 - 3. 构建 Docker 镜像并推至 Docker Hub 本文地址:blog.lucien.ink/archives/498 0. 摘要 之前挖了一个坑,慢慢补上。 上篇文章介绍了如何借助 GitHub Actions 在 Release 时自动上传打包好的工程。本篇文章旨在介绍将 Dockerfile 构建出来的镜像上传至 Docker Hub。 1

  • 首次部署 填写dokcer-compose.yml文件,配置NGINX、Mongo、Node服务等 在对应位置存放项目文件,创建Dockerfile等配置文件 dokcer-compose.yml version: "2" services: nginxproxy: container_name: nginx-proxy restart: always image: n

 相关资料
  • PUBLISH channel message 将信息 message 发送到指定的频道 channel 。 可用版本: >= 2.0.0 时间复杂度: O(N+M),其中 N 是频道 channel 的订阅者数量,而 M 则是使用模式订阅(subscribed patterns)的客户端的数量。 返回值: 接收到信息 message 的订阅者数量。 # 对没有订阅者的频道发送信息 redis>

  • publish 将 Observable 转换为可被连接的 Observable publish 会将 Observable 转换为可被连接的 Observable。可被连接的 Observable 和普通的 Observable 十分相似,不过在被订阅后不会发出元素,直到 connect 操作符被应用为止。这样一来你可以控制 Observable 在什么时候开始发出元素。 演示 let intS

  • publish 函数签名: publish() : ConnectableObservable 共享源 observable 并通过调用 connect 方法使其变成热的。 示例 示例 1: 在订阅之后调用 observable 的 connect 方法 ( StackBlitz | jsBin | jsFiddle ) // RxJS v6+ import { interval } from '

  • npm-publish-action GitHub action to automatically publish packages to npm. Usage Create a new .github/workflows/npm-publish.yml file: name: npm-publishon: push: branches: - main # Change this

  • (要求Workerman版本>=3.3.0) void ChannelClient::publish(string $event_name, mixed $event_data) 发布某个事件,所有这个事件的订阅者会收到这个事件并触发on($event_name, $callback)注册的回调$callback 参数 $event_name 发布的事件名称,可以是任意的字符串。如果事件没有任何订

  • Publishes a package to the npm registry. Once a package is published, you can never modify that specific version, so take care before publishing. yarn publish Publishes the package defined by the pack