-
Notifications
You must be signed in to change notification settings - Fork 3
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
AUT-105: Add GitHub deployment workflow #330
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8a1dff9
YOLO: Let's deploy!
oskirby 5df4770
Attempt version generation
oskirby 01c4a41
We don't really need to keep the sources in the final image
oskirby d909417
Actually version.json is embedded into the binary
oskirby 1b2ea73
Update Makefile to generate version.json
oskirby aab5392
Enable GCP login and artifact upload
oskirby 9218548
Revert in-docker version generation and use the CI env instead
oskirby b9d7aeb
Add version generation to integration tests too
oskirby 1e2d1cb
Fix some shell errors when running version.sh
oskirby f61ca37
Remove CircleCI deploy job
oskirby f73212b
Make pushes dependent on environment variables.
oskirby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Deploy | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '[0-9]+.[0-9a-z]+.[0-9a-z]+' | ||
|
||
jobs: | ||
docker: | ||
name: Docker Images | ||
runs-on: ubuntu-22.04 | ||
environment: build | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Docker Metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ vars.DOCKERHUB_REPO }} | ||
${{ vars.GCP_PROJECT_ID && format('{0}-docker.pkg.dev/{1}/{2}/autograph-edge', vars.GAR_LOCATION, vars.GCP_PROJECT_ID, vars.GAR_REPOSITORY) }} | ||
tags: | | ||
type=semver,pattern={{raw}} | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
- id: gcp-auth | ||
if: ${{ vars.GCP_PROJECT_ID }} | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
service_account: artifact-writer@${{ vars.GCP_PROJECT_ID}}.iam.gserviceaccount.com | ||
workload_identity_provider: ${{ vars.GCPV2_GITHUB_WORKLOAD_IDENTITY_PROVIDER }} | ||
|
||
- name: Login to Google Artifact Registry | ||
if: ${{ vars.GCP_PROJECT_ID }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ vars.GAR_LOCATION }}-docker.pkg.dev | ||
username: oauth2accesstoken | ||
password: ${{ steps.gcp-auth.outputs.access_token }} | ||
|
||
- name: Login to Dockerhub | ||
if: ${{ vars.DOCKERHUB_REPO }} | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Generate version.json | ||
shell: bash | ||
run: ./version.sh | tee version.json | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: ${{ github.event_name != 'pull_request' }} | ||
sbom: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
context: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor/ | ||
version.json | ||
coverage.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
SRCDIR=$(dirname $0) | ||
|
||
if [ -n "$GITHUB_SHA" ]; then | ||
# We are probably running in a Github workflow. | ||
VERSION_SOURCE_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" | ||
VERSION_COMMIT_HASH="$GITHUB_SHA" | ||
VERSION_BUILD_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | ||
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then | ||
VERSION_TAG_NAME="$GITHUB_REF_NAME" | ||
fi | ||
elif [ -n "$CIRCLE_SHA1" ]; then | ||
# We are running in a CircleCI job. | ||
VERSION_SOURCE_URL="https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" | ||
VERSION_COMMIT_HASH="$CIRCLE_SHA1" | ||
VERSION_BUILD_URL="$CIRCLE_BUILD_URL" | ||
VERSION_TAG_NAME="$CIRCLE_TAG" | ||
elif [ -d ${SRCDIR}/.git ]; then | ||
# Otherwise, try to grab version information from the git repository. | ||
VERSION_COMMIT_HASH=$(git -C ${SRCDIR} rev-parse HEAD) | ||
VERSION_SOURCE_URL=$(git -C ${SRCDIR} remote get-url origin) | ||
VERSION_TAG_NAME=$(git -C ${SRCDIR} describe --tags --always) | ||
fi | ||
|
||
# Redirect to a file if provided as an argument. | ||
if [ $# -ge 1 ]; then | ||
exec > $1 | ||
fi | ||
|
||
cat << EOF | ||
{ | ||
"source": "${VERSION_SOURCE_URL}", | ||
"commit": "${VERSION_COMMIT_HASH}", | ||
"version: "${VERSION_TAG_NAME}", | ||
"build: "${VERSION_BUILD_URL}", | ||
} | ||
EOF |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to mkdir before running the ADD on the next line