Build and Deploy Release #217
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: Build and Deploy Release | |
on: | |
release: | |
types: | |
- published | |
workflow_run: | |
branches: | |
- "main" | |
types: | |
- completed | |
workflows: | |
- "Build" | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'release' }} | |
permissions: | |
id-token: write | |
contents: read | |
packages: read | |
actions: read | |
checks: read | |
deployments: read | |
issues: read | |
discussions: read | |
pages: read | |
pull-requests: read | |
repository-projects: read | |
statuses: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifact | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: build.yml | |
workflow_conclusion: success | |
name: tapir | |
path: target/quarkus-app | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
pacovk/tapir | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=schedule,pattern=nightly | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN }} | |
aws-region: eu-central-1 | |
- name: Login to Amazon ECR Public | |
id: login-ecr-public | |
env: | |
AWS_REGION: us-east-1 | |
AWS_DEFAULT_REGION: us-east-1 | |
uses: aws-actions/amazon-ecr-login@v1 | |
with: | |
registry-type: public | |
- name: Tag, and push docker image to Amazon ECR Public | |
env: | |
AWS_REGION: us-east-1 | |
AWS_DEFAULT_REGION: us-east-1 | |
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} | |
REGISTRY_ALIAS: o7d8p0l2 | |
REPOSITORY: tapir | |
IMAGE_TAG: latest | |
run: | | |
docker pull pacovk/tapir | |
docker tag pacovk/tapir $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG | |
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG |