Merge pull request #284 from overmindtech/deadlines #573
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 | |
on: | |
# Trigger the workflow on push or pull request, | |
# but only for the main branch | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v*" | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
env: | |
GOEXPERIMENT: loopvar | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.x | |
check-latest: true | |
- name: Get dependencies | |
run: | | |
go get -v -t -d ./... | |
- name: Vet | |
run: go vet | |
- name: Validate Docs Data | |
run: | | |
mkdir -p ~/.local/bin/ && curl -Lo ~/.local/bin/docgen https://github.com/overmindtech/docgen/releases/latest/download/docgen-amd64 && chmod +x ~/.local/bin/docgen | |
go generate ./... | |
if [ -z "$(git status --porcelain)" ]; then | |
echo "No pending docs changes" | |
else | |
echo "Pending docs changes found, please run 'go generate ./...' and commit the changes" | |
git status | |
exit 1 | |
fi | |
- name: Run tests | |
run: go test ./... | |
env: | |
# Environment variables so that AWS resources can be created | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: eu-west-2 | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} | |
needs: | |
- test | |
permissions: | |
contents: read # required for checkout | |
id-token: write # mint credentials through OIDC | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dockerfile: Dockerfile | |
image_name: aws-source | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/overmindtech/${{ matrix.image_name }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: depot/setup-action@v1 | |
- name: Build and push | |
id: push | |
uses: depot/build-push-action@v1 | |
with: | |
project: x54wnggmpr | |
file: build/package/${{ matrix.dockerfile }} | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Prepare Deployment | |
run: | | |
echo "ghcr.io/overmindtech/${{ matrix.image_name }}@${{ steps.push.outputs.digest }}" | tee ${{ matrix.image_name }}.imageref | |
- name: Upload Deployment File | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.image_name }}.imageref | |
path: ${{ matrix.image_name }}.imageref |