diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..31bfffc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,61 @@ +name: Docker Build Reusable + +on: + workflow_call: + inputs: + push: + required: false + type: boolean + default: false + nginx_version: + required: true + type: string + tags: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + + - name: Log in to Docker Hub + uses: docker/login-action@v4 + if: inputs.push + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Log in to the Container registry + uses: docker/login-action@v4 + if: inputs.push + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker Labels + id: meta + uses: docker/metadata-action@v6 + with: + images: | + cupcakearmy/static + ghcr.io/${{ github.repository }} + tags: ${{ inputs.tags }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: ${{ inputs.push }} + platforms: linux/amd64,linux/arm64 + build-args: NGINX=${{ inputs.nginx_version }} + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 4424f08..6ce2c5e 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -7,59 +7,15 @@ on: jobs: tags: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.fetcher.outputs.matrix }} - defaults: - run: - working-directory: tags - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - - run: bun i - - id: fetcher - run: bun . + uses: ./.github/workflows/tags.yml build: - runs-on: ubuntu-latest needs: tags strategy: matrix: ${{fromJson(needs.tags.outputs.matrix)}} - steps: - - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - install: true - - - name: Log in to Docker Hub - uses: docker/login-action@v4 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Log in to the Container registry - uses: docker/login-action@v4 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker Labels - id: meta - uses: docker/metadata-action@v6 - with: - images: | - cupcakearmy/static - ghcr.io/${{ github.repository }} - tags: ${{ matrix.tags }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v6 - with: - push: true - platforms: linux/amd64,linux/arm64 - build-args: NGINX=${{ matrix.version }} - tags: ${{ steps.meta.outputs.tags }} + uses: ./.github/workflows/build.yml + with: + push: true + nginx_version: ${{ matrix.version }} + tags: ${{ matrix.tags }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..70bcaac --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,18 @@ +name: PR Build + +on: + pull_request: + +jobs: + tags: + uses: ./.github/workflows/tags.yml + + build: + needs: tags + strategy: + matrix: ${{fromJson(needs.tags.outputs.matrix)}} + uses: ./.github/workflows/build.yml + with: + push: false + nginx_version: ${{ matrix.version }} + tags: ${{ matrix.tags }} \ No newline at end of file diff --git a/.github/workflows/tags.yml b/.github/workflows/tags.yml new file mode 100644 index 0000000..3eb7d40 --- /dev/null +++ b/.github/workflows/tags.yml @@ -0,0 +1,23 @@ +name: Fetch Nginx Tags + +on: + workflow_call: + outputs: + matrix: + description: JSON matrix of nginx versions and docker tags + value: ${{ jobs.fetch.outputs.matrix }} + +jobs: + fetch: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.fetcher.outputs.matrix }} + defaults: + run: + working-directory: tags + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - run: bun i + - id: fetcher + run: bun . \ No newline at end of file