-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
68 lines (52 loc) · 1.81 KB
/
azure-pipelines.yml
File metadata and controls
68 lines (52 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
pool:
vmImage: 'ubuntu-latest'
variables:
- group: 'github-config'
stages:
- stage: Test
jobs:
- job:
steps:
- checkout: self
- script: |
# Fail fast
set -euo pipefail
# Echo PHP and Composer versions
php -v
composer --version
# Install dependencies
composer validate --no-interaction --no-ansi
composer install --no-interaction --prefer-dist --no-progress --no-ansi
- script: './vendor/bin/phpunit tests'
displayName: 'Run Tests with PHPUnit'
- stage: GitHub
jobs:
- job:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
steps:
- checkout: self
fetchDepth: 0
- script: |
# Fail fast
set -euo pipefail
# Configure Git identity
git config user.name "azure-devops-bot"
git config user.email "azuredevops@stueber.nomail"
# Add 'github' remote
git remote add github "https://${PAT}@github.com/openpotato/openplzapi-client.php.git"
# Fetch remote main if it exists
git fetch --prune github main || true
# If remote branch exists, only push when remote is an ancestor of HEAD (fast-forward safe)
if git show-ref --verify --quiet refs/remotes/github/main; then
if ! git merge-base --is-ancestor github/main HEAD; then
echo "Remote has commits not in local (or histories diverged). Aborting push." >&2
exit 1
fi
fi
# Push only the main branch (fast-forward or create remote if missing)
git push --tags github HEAD:refs/heads/main
# Remove the remote so the PAT isn't left in .git/config
git remote remove github || true
displayName: 'Push to GitHub'
env:
PAT: $(PAT)