Skip to content

Commit

Permalink
Update actions and add docker workflow (phpvms#1926)
Browse files Browse the repository at this point in the history
* Upgrade artifact actions to v4

* Add docker workflow

* Update deprecated set-ouput commands

* Update docker workflow

* Update docker workflow

* Update docker workflow

---------

Co-authored-by: Nabeel S. <[email protected]>
  • Loading branch information
arthurpar06 and nabeelio authored Jan 10, 2025
1 parent 7e30259 commit 1d24528
Showing 1 changed file with 56 additions and 4 deletions.
60 changes: 56 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
- main
- dev
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -48,7 +53,7 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
Expand Down Expand Up @@ -131,7 +136,7 @@ jobs:
# Configure Caching
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
Expand Down Expand Up @@ -193,7 +198,7 @@ jobs:
args: ${{ steps.discord.outputs.discord_msg }}

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: phpvms-package
path: 'dist/*'
Expand All @@ -219,7 +224,7 @@ jobs:
steps:

- name: Download artifact from build job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: phpvms-package

Expand All @@ -237,3 +242,50 @@ jobs:
name: ${{ github.ref_name }}
tag: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}

docker:
name: 'Create docker image'
runs-on: ubuntu-latest
needs: [build]
if: github.repository == 'nabeelio/phpvms' && github.event_name != 'pull_request'
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
id: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit 1d24528

Please sign in to comment.