Update docker-compose-pull.yml (#522) #262
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will test if pulling the latest Docker Compose containers from the registry works. | |
name: Docker Compose Pull | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
test-docker: | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:26.0.0 | |
options: --privileged | |
steps: | |
- name: Get repository and branch information | |
id: repo-info | |
run: | | |
# Check if this is a PR from a fork | |
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ github.event.pull_request.head.repo.fork }}" = "true" ]; then | |
# If PR is from a fork, use main branch from lanedirt/AliasVault | |
echo "REPO_FULL_NAME=lanedirt/AliasVault" >> $GITHUB_ENV | |
echo "BRANCH_NAME=main" >> $GITHUB_ENV | |
else | |
# Otherwise use the current repository and branch | |
echo "REPO_FULL_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_ENV | |
echo "BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV | |
fi | |
- name: Download install script from current branch | |
run: | | |
INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/$REPO_FULL_NAME/$BRANCH_NAME/install.sh" | |
echo "Downloading install script from: $INSTALL_SCRIPT_URL" | |
curl -f -o install.sh "$INSTALL_SCRIPT_URL" | |
- name: Create .env file with custom SMTP port as port 25 is not allowed in GitHub Actions | |
run: | | |
echo "SMTP_PORT=2525" > .env | |
- name: Set permissions and run install.sh | |
id: install_script | |
continue-on-error: true | |
run: | | |
chmod +x install.sh | |
./install.sh install --verbose | |
- name: Check if failure was due to version mismatch | |
if: steps.install_script.outcome == 'failure' | |
run: | | |
if grep -q "Install script needs updating to match version" <<< "$(./install.sh install --verbose 2>&1)"; then | |
echo "Test skipped: Install script version is newer than latest release version. This is expected behavior if the install script is run on a branch that is ahead of the latest release." | |
exit 0 | |
else | |
echo "Test failed due to an unexpected error" | |
exit 1 | |
fi | |
- name: Set up Docker Compose | |
run: docker compose -f docker-compose.yml up -d | |
- name: Wait for services to be up | |
run: | | |
# Wait for a few seconds | |
sleep 10 | |
- name: Test if localhost:443 (WASM app) responds | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 2 | |
max_attempts: 3 | |
command: | | |
http_code=$(curl -k -s -o /dev/null -w "%{http_code}" https://localhost:443) | |
if [ "$http_code" -ne 200 ]; then | |
echo "Service did not respond with 200 OK. Check if client app and/or nginx is configured correctly." | |
exit 1 | |
else | |
echo "Service responded with 200 OK" | |
fi | |
- name: Test if localhost:443/api (WebApi) responds | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 2 | |
max_attempts: 3 | |
command: | | |
http_code=$(curl -k -s -o /dev/null -w "%{http_code}" https://localhost:443/api) | |
if [ "$http_code" -ne 200 ]; then | |
echo "Service did not respond with expected 200 OK. Check if WebApi and/or nginx is configured correctly." | |
exit 1 | |
else | |
echo "Service responded with $http_code" | |
fi | |
- name: Test if localhost:443/admin (Admin) responds | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 2 | |
max_attempts: 3 | |
command: | | |
http_code=$(curl -k -s -o /dev/null -w "%{http_code}" https://localhost:443/admin/user/login) | |
if [ "$http_code" -ne 200 ]; then | |
echo "Service did not respond with expected 200 OK. Check if admin app and/or nginx is configured correctly." | |
exit 1 | |
else | |
echo "Service responded with $http_code" | |
fi | |
- name: Test if localhost:2525 (SmtpService) responds | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 2 | |
max_attempts: 3 | |
command: | | |
if ! nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then | |
echo "SmtpService did not respond on port 2525. Check if the SmtpService service is running." | |
exit 1 | |
else | |
echo "SmtpService responded on port 2525" | |
fi | |
- name: Test install.sh reset-password output | |
run: | | |
output=$(./install.sh reset-password) | |
if ! echo "$output" | grep -E '.*New admin password: [A-Za-z0-9+/=]{8,}.*'; then | |
echo "Password reset output format is incorrect. Expected format: 'New admin password: <at least 8 base64 chars>'" | |
echo "Actual output: $output" | |
exit 1 | |
else | |
echo "Password reset output format is correct" | |
fi |