Change redirectURL to Support Build web on Github Deployment #8
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
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v*.*.*" | |
name: Build Docker images | |
permissions: | |
pull-requests: read | |
contents: read | |
packages: write | |
jobs: | |
build_dev_image: | |
name: Build development image | |
if: github.ref_type == 'branch' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_KEY }} | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository_owner }}/twake-web | |
ghcr.io/${{ github.repository_owner }}/twake-web | |
tags: | | |
type=ref,event=branch | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
cache-from: | | |
type=gha | |
cache-to: | | |
type=gha | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
ssh: | | |
default | |
build_release_image: | |
name: Build release image | |
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
environment: prod | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_KEY }} | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ github.repository_owner }}/twake-web | |
ghcr.io/${{ github.repository_owner }}/twake-web | |
tags: | | |
type=ref,event=tag | |
type=raw,value=release | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
cache-from: | | |
type=gha | |
cache-to: | | |
type=gha | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
ssh: | | |
default |