Skip to content

Commit

Permalink
Merge pull request codfish#156 from codfish/gcr
Browse files Browse the repository at this point in the history
perf: push docker images to gcr
  • Loading branch information
codfish authored Jan 30, 2021
2 parents 7de387a + 35ba549 commit b874e56
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 16 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,26 @@ jobs:
echo "$RELEASE_PATCH"
env:
OUTPUTS: ${{ toJson(steps.semantic.outputs) }}

- name: docker login
run: |
echo "$GCR_TOKEN" | docker login ghcr.io -u codfish --password-stdin
env:
GCR_TOKEN: ${{ secrets.GCR_TOKEN }}

# Dockerhub is auto synced with the repo, no need to explicitly deploy
- name: build and push latest docker image to GCR
run: |
docker build -t ghcr.io/codfish/semantic-release-action:latest .
docker push ghcr.io/codfish/semantic-release-action:latest
- name: push docker images for releases to GCR
if: steps.semantic.outputs.new-release-published == 'true'
run: |
docker tag ghcr.io/codfish/semantic-release-action ghcr.io/codfish/semantic-release-action:$VERSION_TAG
docker tag ghcr.io/codfish/semantic-release-action ghcr.io/codfish/semantic-release-action:$MAJOR_TAG
docker push ghcr.io/codfish/semantic-release-action:$VERSION_TAG
docker push ghcr.io/codfish/semantic-release-action:$MAJOR_TAG
env:
VERSION_TAG: v${{ steps.semantic.outputs.release-version }}
MAJOR_TAG: v${{ steps.semantic.outputs.release-major }}
46 changes: 30 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Usage](#usage)
- [Basic Usage](#basic-usage)
- [Why](#why)
- [Configuration](#configuration)
- [Example with all inputs](#example-with-all-inputs)
Expand All @@ -19,26 +20,39 @@

See [action.yml](action.yml).

- Use major version
([recommended by GitHub](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)):
`uses: codfish/semantic-release-action@v1`
- Use latest version: `uses: codfish/semantic-release-action@v1`
- Use specific version: `uses: codfish/[email protected]`
Referencing the major version is
([recommended by GitHub](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)).

**Note**: You can speed up runs by using pre-built docker images as well.
```yml
steps:
# Reference the major version of a release
- uses: codfish/semantic-release-action@v1
# Reference a specific commit
- uses: codfish/semantic-release-action@c4074285a1651e4fecab9c14974d5e01b4625edf
# Reference a minor version of a release
- uses: codfish/[email protected]
# Reference a branch
- uses: codfish/semantic-release-action@master
```
> **Note**: Whenever you use a custom docker-based GitHub Action like this one, you may notice in
> your run logs, one of the first steps you'll see will be GA building the image for you. You can
> speed up runs by pulling pre-built docker images instead of making GitHub Actions build them on
> every run.
```yml
- uses: docker://codfish/semantic-release-action:v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
# Reference a docker image from GitHub Container Registry
- uses: docker://ghcr.io/codfish/semantic-release-action@v1
# Reference a docker image from Dockerhub
- uses: docker://codfish/semantic-release-action@v1
```
**Basic Usage:**
### Basic Usage
```yml
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1

- uses: codfish/semantic-release-action@v1
env:
Expand All @@ -50,7 +64,7 @@ steps:

```yml
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
# you'll need to add an `id` in order to access output variables
- uses: codfish/semantic-release-action@v1
Expand All @@ -70,11 +84,11 @@ steps:
release-version: ${{ steps.semantic.outputs.release-version }}
```
**Only run an action if a new version was created:**
**Example:** Only run an action if a new version was created.
```yml
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1

# you'll need to add an `id` in order to access output variables
- uses: codfish/semantic-release-action@v1
Expand All @@ -96,7 +110,7 @@ steps:

```yml
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
- uses: codfish/semantic-release-action@v1
env:
Expand Down

0 comments on commit b874e56

Please sign in to comment.