Skip to content

Default asserts_site to region in resource relation #178

Default asserts_site to region in resource relation

Default asserts_site to region in resource relation #178

Workflow file for this run

name: Build, Publish Aws-Exporter
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- 'v*'
env:
REGISTRY: asserts
jobs:
lint:
name: Lint Helm Chart
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml
build:
name: Build Aws-Exporter
runs-on: ubuntu-20.04
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Check with Gradle
run: ./gradlew check
- name: Get repository name
run: |
REPO_NAME=${GITHUB_REPOSITORY#*/}
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV
- name: Docker metadata
id: meta-pr
uses: docker/metadata-action@v4
if: github.event_name == 'pull_request'
with:
images: ${{ env.REGISTRY}}/${{ env.REPO_NAME }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
- name: Docker metadata
id: meta-merge
uses: docker/metadata-action@v4
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
with:
images: ${{ env.REGISTRY}}/${{ env.REPO_NAME }}
tags: |
type=schedule
type=sha
- name: Docker metadata
id: meta-tag
uses: docker/metadata-action@v4
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
with:
images: ${{ env.REGISTRY}}/${{ env.REPO_NAME }}
tags: |
type=schedule
type=ref,event=tag
type=raw,value=latest-release
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push pr
uses: docker/build-push-action@v4
if: github.event_name == 'pull_request'
with:
context: '.'
push: true
tags: ${{ steps.meta-pr.outputs.tags }}
- name: Build and push merge
uses: docker/build-push-action@v4
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
with:
context: '.'
push: true
tags: ${{ steps.meta-merge.outputs.tags }}
- name: Build and push tag
uses: docker/build-push-action@v4
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
with:
context: '.'
push: true
tags: ${{ steps.meta-tag.outputs.tags }}
publish-artifact:
name: Publish Aws-Exporter
runs-on: ubuntu-20.04
needs: build
if: github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/')
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_DEFAULT_REGION: us-west-2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
role-duration-seconds: 1200
role-session-name: BuildSession
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Gradle Build
run: ./gradlew build
- name: Publish Config with Gradle
run: ./gradlew publish
- name: Clear session
run: |
echo "AWS_ACCOUNT_ID=" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=" >> $GITHUB_ENV
echo "AWS_SESSION_TOKEN=" >> $GITHUB_ENV