Skip to content

[pre-commit.ci] pre-commit autoupdate (#259) #452

[pre-commit.ci] pre-commit autoupdate (#259)

[pre-commit.ci] pre-commit autoupdate (#259) #452

name: Docker Sanic
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
paths-ignore:
- 'natural4-server/Docker/nginx/**'
- 'natural4-server/Docker/webapi-ci/**'
- '.github/workflows/docker-publish-nginx.yml'
- '.github/workflows/docker-publish-webapi-ci.yml'
pull_request:
branches: [ "main" ]
paths-ignore:
- 'natural4-server/Docker/nginx/**'
- 'natural4-server/Docker/webapi-ci/**'
- '.github/workflows/docker-publish-nginx.yml'
- '.github/workflows/docker-publish-webapi-ci.yml'
workflow_dispatch:
inputs:
dsl_app_tag_input:
description: 'Tag of the DSL Docker container'
required: false
type: string
default: main
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: smucclaw/dsl-app
DSL_CONTAINER_TAG: ${{ inputs.dsl_app_tag_input || 'main' }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::534084562538:role/github-actions-role
aws-region: ap-southeast-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: 'natural4-server/Docker/sanic/'
build-args: |
DSL_TAG=${{ env.DSL_CONTAINER_TAG }}
build-contexts: |
gsheet=${{ github.workspace }}
dsl=https://github.com/smucclaw/dsl.git
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max