Skip to content

Commit

Permalink
docs: Add GitHub Workflow to Ephemeral Environments guide
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Feb 24, 2025
1 parent 901ab22 commit 20f2904
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/operator/resourcesets/github-pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,54 @@ spec:
region: "us-east-1"
```

## GitHub Workflow

To automate the build and push of the app container image to GitHub Container Registry,
the GitHub Actions workflow should include the following steps:

```yaml
name: push-image-preview
on:
pull_request:
branches: ['main']
jobs:
docker:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ github.event.pull_request.head.sha }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
push: true
context: .
file: ./Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
```

Note that we tag the container image with `${{ github.event.pull_request.head.sha }}`.
This ensures that the image tag matches the commit SHA of the PR HEAD that the ResourceSet
uses to deploy the app.

## Further reading

To learn more about ResourceSets and the various configuration options, see the following docs:
Expand Down

0 comments on commit 20f2904

Please sign in to comment.