Skip to content

Instantly share code, notes, and snippets.

@ajardin
Created May 6, 2024 21:22
Show Gist options
  • Save ajardin/a9edfdc3c1ecb2b2a046465f82d4454c to your computer and use it in GitHub Desktop.
Save ajardin/a9edfdc3c1ecb2b2a046465f82d4454c to your computer and use it in GitHub Desktop.
Distributing projects compiled into PHAR
name: Continuous Deployment
on:
push:
branches: ['master']
jobs:
tests:
name: Deployment
runs-on: ubuntu-latest
steps:
- name: 'Prepare the build context'
uses: actions/checkout@v1
- name: 'Install system requirements'
run: |
sudo apt update
sudo apt install -y libicu-dev
sudo apt-fast install -y --no-install-recommends \
php7.4 php7.4-ctype php7.4-intl php7.4-mbstring php7.4-pcov php7.4-sqlite php7.4-xml
- name: 'Load the keys used to deploy the PHAR archive'
run: |
mkdir -p ~/.ssh
echo "${{ secrets.PRIVATE_DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.PRIVATE_SIGNING_KEY }}" | gpg --import
- name: 'Configure the committer identity'
run: |
git config --global user.email "[email protected]"
git config --global user.name "Firstname Lastname"
git config --global commit.gpgsign "true"
git config --global user.signingkey "XXXXXXXXXXXXXXXX"
- name: 'Install Composer dependencies'
run: |
composer validate --strict --ansi
composer install --optimize-autoloader --classmap-authoritative --ansi
- name: 'Compile the PHAR archive'
run: |
composer dump-env prod
./bin/console cache:warmup
docker run --volume="$(pwd):/app:delegated" ajardin/humbug-box compile --ansi
- name: 'Prepare the local Git repository which contains the PHAR archive'
run: |
git clone [email protected]:origanization/project.git /tmp/project
mkdir -p /tmp/project/bin/
cp ./build/project.phar /tmp/project/bin/project
- name: 'Update the remote Git repository which contains the PHAR archive'
run: |
cd /tmp/project
git add bin/project
git commit --message="Update to commit https://github.com/origanization/project-source/commit/${{ github.sha }}"
git push origin HEAD:master
name: Release Version
on:
push:
tags: ['v*.*.*']
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
# [...]
- name: 'Update the remote Git repository which contains the PHAR archive'
run: |
tag_name=$(git show "${{ github.ref }}" --no-patch --format="" | head -n1 | awk '{print $2}')
tag_message=$(git show "${{ github.ref }}" --no-patch --format="" | tail -n1)
cd /tmp/project
git add bin/project
git commit --message="Update to version ${tag_name}"
git push origin HEAD:master
git tag "${tag_name}" --message="${tag_message}" --force --sign
git push origin "${tag_name}" --force
{
"name": "organization/project",
"...": "...",
"bin": "bin/xyz"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment