Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add GitHub Actions example for container image #33

Merged
merged 5 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
branches:
- main
pull_request:
paths-ignore: ["**.md"]

jobs:
docker:
Expand Down
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,74 @@ rm -rf /tmp/golang-tip && tar -C /tmp -xzf master.tmp.tar.gz
/tmp/golang-tip/bin/go env
```

## Using golang-tip in GitHub Actions

Examples for using golang-tip in a GitHub Action.

### .tar.gz

> This example shows how to use golang-tip's .tar.gz release format
within a GitHub Actions runner. We first purge an existing Go installation.
If you are looking to save on Actions minutes, this workflow takes
less than half the time to run as the container example below.

```yaml
# Remove existing Go installation, install golang-tip from latest .tar.gz
# More .tar.gz releases can be found here: https://github.com/AlekSi/golang-tip/releases/tag/tip

# action.yml
---
name: Go unit tests with golang-tip
on:
pull_request:
jobs:
test-my-app-targz:
name: test my golang app using golang-tip .tar.gz release
runs-on: ubuntu-latest
steps:
- name: Remove existing go installation from Actions runner
run: |
sudo rm -fr /opt/hostedtoolcache/go /usr/local/go /usr/bin/go /bin/go
- name: Install latest golang-tip on Actions runner
run: |
curl -o go.tar.gz -L \
https://github.com/AlekSi/golang-tip/releases/download/tip/master.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go.tar.gz
sudo ln -s /usr/local/go/bin/* /usr/local/bin/
- uses: actions/checkout@v2
- name: run tests
run: go test ./...
```

### Container image

> This example shows how you can use golang-tip's prebuilt container image
directly within your GitHub Action Workflow. All `steps` are executed within
the container image at `ghcr.io/aleksi/golang-tip:master` for the `test-my-app`
Job.

```yaml
# Run your Job within latest golang-tip built container.
# Use head of golang-tip aka "master" or other available image tags here:
# https://github.com/AlekSi/golang-tip/pkgs/container/golang-tip

# action.yml
---
name: Go unit tests with golang-tip
on:
pull_request:
jobs:
test-my-app-oci:
name: test my golang app using golang-tip container release
runs-on: ubuntu-latest
container:
# image: ghcr.io/aleksi/golang-tip:dev.boringcrypto
image: ghcr.io/aleksi/golang-tip:master
steps:
- uses: actions/checkout@v2
- name: run tests
run: go test ./...
```

# Branches

Expand All @@ -61,7 +129,7 @@ FROM ghcr.io/aleksi/golang-tip:master
```


# .tag.gz
# .tar.gz
kevholmes marked this conversation as resolved.
Show resolved Hide resolved

`.tar.gz` files are provided in two variants. The main one behaves like [the official Go release](https://golang.org/doc/install) -
it is expected to be unpacked into `/usr/local` as `/usr/local/go`:
Expand Down