upload bundles directly after fetching #134
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
name: Test, Build Image & Push to ECR | |
on: | |
push: | |
branches: | |
- main # Trigger the workflow on pushes to the main branch | |
tags: | |
- "**" # Trigger the workflow on tags including hierarchical tags like v1.0/beta | |
pull_request: | |
types: [opened, synchronize] # Trigger the workflow when a PR is opened or updated | |
env: | |
RELEASE_REVISION: ${{ github.sha }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
ECR_REPOSITORY: lightlink-hummingbird | |
jobs: | |
test: | |
name: Run Go Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21.5 | |
- name: Test | |
run: go test -v ./... | |
release: | |
needs: test | |
name: Build Image & Push to ECR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.sha }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker cache layers | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-single-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-single-buildx | |
- name: Get the version tag or short SHA | |
id: get-tag | |
run: | | |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
echo "::set-output name=version::${GITHUB_REF#refs/tags/}" | |
else | |
echo "::set-output name=version::${GITHUB_SHA::7}" | |
fi | |
- name: Push Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ steps.get-tag.outputs.version }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
build-args: VERSION=${{ steps.get-tag.outputs.version }} | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |