Merge pull request #217 from rebuy-de/dependabot/go_modules/golang-dd… #646
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: Golang | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
types: [opened, reopened, synchronize] | |
release: | |
types: [published] | |
schedule: | |
- cron: '15 3 * * 0' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
name: CI Build | |
steps: | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
- name: Setup tools | |
run: | | |
go install golang.org/x/lint/golint@latest | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build Project | |
run: ./buildutil -v | |
container_build: | |
runs-on: ubuntu-22.04 | |
name: Container Build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate image tags for releaes | |
if: ${{ github.event_name == 'release' }} | |
shell: bash | |
run: echo "tags=quay.io/rebuy/cost-exporter:${GITHUB_REF#refs/tags/},074509403805.dkr.ecr.eu-west-1.amazonaws.com/cost-exporter:${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
id: generate_tags_release | |
- name: Generate image tags for PRs | |
if: ${{ github.event_name != 'release' }} | |
shell: bash | |
run: | | |
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then | |
BRANCH="$(echo ${GITHUB_HEAD_REF} | tr '/' '_')" | |
echo "tags=quay.io/rebuy/cost-exporter:${BRANCH},074509403805.dkr.ecr.eu-west-1.amazonaws.com/cost-exporter:${BRANCH}" >> $GITHUB_OUTPUT | |
else | |
echo "tags=quay.io/rebuy/cost-exporter:main,074509403805.dkr.ecr.eu-west-1.amazonaws.com/cost-exporter:main,\ | |
quay.io/rebuy/cost-exporter:latest,074509403805.dkr.ecr.eu-west-1.amazonaws.com/cost-exporter:latest" >> $GITHUB_OUTPUT | |
fi | |
id: generate_tags_pr | |
- name: Set up QEMU | |
if: ${{ github.event_name == 'release' }} | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
# Only used to prevent rate limits | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to ECR | |
uses: docker/login-action@v3 | |
with: | |
registry: 074509403805.dkr.ecr.eu-west-1.amazonaws.com | |
username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }} | |
password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }} | |
- name: Login to Quay.io | |
uses: docker/login-action@v3 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Build and push | |
if: ${{ github.event_name == 'release' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.generate_tags_release.outputs.tags }} | |
platforms: linux/amd64,linux/arm64 | |
- name: Build and push | |
if: ${{ github.event_name != 'release' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.generate_tags_pr.outputs.tags }} | |
platforms: linux/amd64 |