Skip to content

Commit

Permalink
Improve CI/CD schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tiaga authored Oct 18, 2024
1 parent 5e93984 commit 39d21bf
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
name: Build docker image
name: Build Docker Image

on:
push:
branches:
- main
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:

env:
APP: amnezia-xray-core

jobs:
build-image:
runs-on: ubuntu-latest
permissions:
packages: write
name: build-image
steps:
- uses: actions/checkout@v4
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/amnezia-xray-core
flavor: latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Login to GitHub Container Registry
- name: Checkout
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- # Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Setup metadata
uses: docker/metadata-action@v5
id: metadata
with:
images: amneziavpn/${{ env.APP }}
tags: type=semver,pattern={{version}}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5

- name: Build
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
context: .
platforms: linux/amd64,linux/arm64
file: .github/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ contains(github.ref, 'refs/tags/') }} # push if tag was set
tags: ${{ steps.metadata.outputs.tags }}

0 comments on commit 39d21bf

Please sign in to comment.