Skip to content

Commit 67598d0

Browse files
Update README.md and docs (#10)
Co-authored-by: goruha <[email protected]>
1 parent 5e8b431 commit 67598d0

File tree

1 file changed

+136
-38
lines changed

1 file changed

+136
-38
lines changed

README.md

Lines changed: 136 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<!-- markdownlint-disable -->
3-
# example-github-action-composite [![Latest Release](https://img.shields.io/github/release/cloudposse/example-github-action-composite.svg)](https://github.com/cloudposse/example-github-action-composite/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
3+
# github-action-docker-promote [![Latest Release](https://img.shields.io/github/release/cloudposse/github-action-docker-promote.svg)](https://github.com/cloudposse/github-action-docker-promote/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
44
<!-- markdownlint-restore -->
55

66
[![README Header][readme_header_img]][readme_header_link]
@@ -28,7 +28,7 @@
2828
2929
-->
3030

31-
Template repository of composite GitHub Action
31+
Promote docker image
3232

3333
---
3434

@@ -58,8 +58,8 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE).
5858

5959
## Introduction
6060

61-
This is template repository to create composite GitHub Actions.
62-
Feel free to use it as reference and starting point.
61+
Promote Docker image to specific tags provided explicitly or implicitly with
62+
[Docker Metadata action](https://github.com/marketplace/actions/docker-metadata-action)
6363

6464

6565

@@ -69,6 +69,45 @@ Feel free to use it as reference and starting point.
6969

7070

7171

72+
### Promote a docker image to specific tag
73+
74+
```yaml
75+
name: Release
76+
on:
77+
release:
78+
types: [published]
79+
80+
permissions:
81+
id-token: write
82+
contents: write
83+
84+
jobs:
85+
promote:
86+
runs-on: ubuntu-latest
87+
steps:
88+
- name: Docker image promote
89+
uses: cloudposse/github-action-docker-promote@main
90+
id: promote
91+
with:
92+
registry: registry.hub.docker.com
93+
organization: ${{ github.event.repository.owner.login }}
94+
repository: ${{ github.event.repository.name }}
95+
login: ${{ secrets.DOCKERHUB_USERNAME }}
96+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
97+
from: sha-${{ github.sha }}
98+
to: ${{ github.event.release.tag_name }}
99+
use_metadata: false
100+
101+
outputs:
102+
image: ${{ steps.promote.outputs.image }}
103+
tag: ${{ steps.promote.outputs.tag }}
104+
```
105+
106+
### Promote a docker image to tags detected from metadata
107+
108+
Promote action use [Docker Metadata action](https://github.com/marketplace/actions/docker-metadata-action) under the
109+
hood and can detect `to` tags based on Git reference and GitHub events.
110+
72111
```yaml
73112
name: Pull Request
74113
on:
@@ -80,14 +119,70 @@ Feel free to use it as reference and starting point.
80119
context:
81120
runs-on: ubuntu-latest
82121
steps:
83-
- name: Example action
84-
uses: cloudposse/example-github-action-composite@main
85-
id: example
122+
123+
- name: Checkout
124+
uses: actions/checkout@v3
125+
with:
126+
fetch-depth: 2
127+
128+
- name: Get previous commit
129+
id: prev-commit
130+
run: echo "sha=$(git rev-parse --verify HEAD^1)" >> $GITHUB_OUTPUT
131+
132+
- name: Docker image promote
133+
uses: cloudposse/github-action-docker-promote@main
134+
id: promote
135+
with:
136+
registry: registry.hub.docker.com
137+
organization: ${{ github.event.repository.owner.login }}
138+
repository: ${{ github.event.repository.name }}
139+
login: ${{ secrets.DOCKERHUB_USERNAME }}
140+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
141+
from: sha-${{ steps.prev-commit.outputs.sha }}
142+
use_metadata: true
143+
144+
outputs:
145+
image: ${{ steps.promote.outputs.image }}
146+
tag: ${{ steps.promote.outputs.tag }}
147+
```
148+
149+
### Promote a docker image with `from` fetched from metadata
150+
151+
If you skip `from` tag then it would be populated as SHA of the current commit in long format.
152+
153+
```yaml
154+
name: Release
155+
on:
156+
release:
157+
types: [published]
158+
159+
permissions:
160+
id-token: write
161+
contents: write
162+
163+
jobs:
164+
promote:
165+
runs-on: ubuntu-latest
166+
steps:
167+
- name: Checkout
168+
uses: actions/checkout@v3
169+
170+
- name: Docker image promote
171+
uses: cloudposse/github-action-docker-promote@main
172+
id: promote
86173
with:
87-
param1: true
174+
registry: registry.hub.docker.com
175+
organization: ${{ github.event.repository.owner.login }}
176+
repository: ${{ github.event.repository.name }}
177+
login: ${{ secrets.DOCKERHUB_USERNAME }}
178+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
179+
## `from` is long SHA
180+
to: ${{ github.event.release.tag_name }}
181+
use_metadata: true
88182

89183
outputs:
90-
result: ${{ steps.example.outputs.result1 }}
184+
image: ${{ steps.promote.outputs.image }}
185+
tag: ${{ steps.promote.outputs.tag }}
91186
```
92187
93188
@@ -123,7 +218,7 @@ Feel free to use it as reference and starting point.
123218
124219
## Share the Love
125220
126-
Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/example-github-action-composite)! (it helps us **a lot**)
221+
Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/github-action-docker-promote)! (it helps us **a lot**)
127222
128223
Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =)
129224
@@ -133,12 +228,15 @@ Are you using this project or any of our other projects? Consider [leaving a tes
133228
134229
Check out these related projects.
135230
231+
- [github-action-docker-build-push](https://github.com/cloudposse/github-action-docker-build-push) - Build Docker image and push it
232+
- [github-action-docker-image-exists](https://github.com/cloudposse/github-action-docker-image-exists) - Check if docker image exists by pulling it
136233
137234
138235
## References
139236
140237
For additional context, refer to some of these links.
141238
239+
- [docker-metadata-action](https://github.com/marketplace/actions/docker-metadata-action) - GitHub Action to extract metadata from Git reference and GitHub events.
142240
- [github-actions-workflows](https://github.com/cloudposse/github-actions-workflows) - Reusable workflows for different types of projects
143241
- [example-github-action-release-workflow](https://github.com/cloudposse/example-github-action-release-workflow) - Example application with complicated release workflow
144242
@@ -147,7 +245,7 @@ For additional context, refer to some of these links.
147245
148246
**Got a question?** We got answers.
149247
150-
File a GitHub [issue](https://github.com/cloudposse/example-github-action-composite/issues), send us an [email][email] or join our [Slack Community][slack].
248+
File a GitHub [issue](https://github.com/cloudposse/github-action-docker-promote/issues), send us an [email][email] or join our [Slack Community][slack].
151249
152250
[![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link]
153251
@@ -195,7 +293,7 @@ Sign up for [our newsletter][newsletter] that covers everything on our technolog
195293
196294
### Bug Reports & Feature Requests
197295
198-
Please use the [issue tracker](https://github.com/cloudposse/example-github-action-composite/issues) to report any bugs or file feature requests.
296+
Please use the [issue tracker](https://github.com/cloudposse/github-action-docker-promote/issues) to report any bugs or file feature requests.
199297
200298
### Developing
201299
@@ -283,33 +381,33 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
283381
[![Beacon][beacon]][website]
284382
<!-- markdownlint-disable -->
285383
[logo]: https://cloudposse.com/logo-300x69.svg
286-
[docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=docs
287-
[website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=website
288-
[github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=github
289-
[jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=jobs
290-
[hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=hire
291-
[slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=slack
292-
[linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=linkedin
293-
[twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=twitter
294-
[testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=testimonial
295-
[office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=office_hours
296-
[newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=newsletter
297-
[discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=discourse
298-
[email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=email
299-
[commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=commercial_support
300-
[we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=we_love_open_source
301-
[terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=terraform_modules
384+
[docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=docs
385+
[website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=website
386+
[github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=github
387+
[jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=jobs
388+
[hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=hire
389+
[slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=slack
390+
[linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=linkedin
391+
[twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=twitter
392+
[testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=testimonial
393+
[office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=office_hours
394+
[newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=newsletter
395+
[discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=discourse
396+
[email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=email
397+
[commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=commercial_support
398+
[we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=we_love_open_source
399+
[terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=terraform_modules
302400
[readme_header_img]: https://cloudposse.com/readme/header/img
303-
[readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=readme_header_link
401+
[readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=readme_header_link
304402
[readme_footer_img]: https://cloudposse.com/readme/footer/img
305-
[readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=readme_footer_link
403+
[readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=readme_footer_link
306404
[readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img
307-
[readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/example-github-action-composite&utm_content=readme_commercial_support_link
308-
[share_twitter]: https://twitter.com/intent/tweet/?text=example-github-action-composite&url=https://github.com/cloudposse/example-github-action-composite
309-
[share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=example-github-action-composite&url=https://github.com/cloudposse/example-github-action-composite
310-
[share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/example-github-action-composite
311-
[share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/example-github-action-composite
312-
[share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/example-github-action-composite
313-
[share_email]: mailto:?subject=example-github-action-composite&body=https://github.com/cloudposse/example-github-action-composite
314-
[beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/example-github-action-composite?pixel&cs=github&cm=readme&an=example-github-action-composite
405+
[readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-docker-promote&utm_content=readme_commercial_support_link
406+
[share_twitter]: https://twitter.com/intent/tweet/?text=github-action-docker-promote&url=https://github.com/cloudposse/github-action-docker-promote
407+
[share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=github-action-docker-promote&url=https://github.com/cloudposse/github-action-docker-promote
408+
[share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/github-action-docker-promote
409+
[share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/github-action-docker-promote
410+
[share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/github-action-docker-promote
411+
[share_email]: mailto:?subject=github-action-docker-promote&body=https://github.com/cloudposse/github-action-docker-promote
412+
[beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/github-action-docker-promote?pixel&cs=github&cm=readme&an=github-action-docker-promote
315413
<!-- markdownlint-restore -->

0 commit comments

Comments
 (0)