Skip to content

Commit

Permalink
[ci] Unified github action files #303
Browse files Browse the repository at this point in the history
Closes #303
  • Loading branch information
pandafy committed Jul 19, 2024
1 parent a04769e commit 7e379a0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 71 deletions.
62 changes: 0 additions & 62 deletions .github/workflows/branch.yml

This file was deleted.

53 changes: 44 additions & 9 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,35 @@ on:
jobs:
build:
name: CI Build
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Git Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install Testing Requirements
- name: Setup testing environment
id: deps
run: |
echo "127.0.0.1 dashboard.openwisp.org api.openwisp.org" | sudo tee -a /etc/hosts
# disable metric collection during builds
sed -i 's/METRIC_COLLECTION=True/METRIC_COLLECTION=False/' .env
sudo pip install -r requirements-test.txt
sudo curl -sL -o /bin/hadolint "https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64"
sudo chmod +x /bin/hadolint
- name: QA checks
run: ./run-qa-checks

- name: Setup
run: |
echo "127.0.0.1 dashboard.openwisp.org api.openwisp.org" | sudo tee -a /etc/hosts
# disable metric collection during builds
sed -i 's/METRIC_COLLECTION=True/METRIC_COLLECTION=False/' .env
run: exit 1

- name: Build Images
# id: build_images
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
run: make compose-build nfs-build

- name: Use auto-install script to start containers
# id: start_containers
# if: ${{ !cancelled() && steps.build_images.conclusion == 'success' }}
# Do not remove the blank lines from the input.
run: |
(GIT_BRANCH="${{ github.head_ref }}" SKIP_PULL=true sudo -E ./deploy/auto-install.sh <<EOF
Expand All @@ -49,6 +52,7 @@ jobs:
) || cat /opt/openwisp/autoinstall.log
- name: Test
# if: ${{ !cancelled() && steps.start_containers.conclusion == 'success' }}
# The auto-install script installs docker-openwisp by default in
# /opt/openwisp/docker-openwisp. To ensure the test runs correctly
# and environment variables remain intact, it is essential to
Expand All @@ -58,3 +62,34 @@ jobs:
working-directory: /opt/openwisp/docker-openwisp
env:
SELENIUM_HEADLESS: 1

# the following action is equivalent to
# echo "$DOCKER_HUB_SECRET" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_SECRET }}

# Skip image builds and tests since they were already done
- name: Publish to Docker Hub
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
make publish USER=docker.io/openwisp TAG=edge SKIP_BUILD=true SKIP_TESTS=true
env:
SELENIUM_HEADLESS: 1

- name: Login to GitLab Container Registry
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: docker/login-action@v1
with:
registry: registry.gitlab.com
username: ${{ secrets.GITLAB_DOCKER_REGISTRY_USER }}
password: ${{ secrets.GITLAB_DOCKER_REGISTRY_TOKEN }}

# Skip image builds and tests since they were already done
- name: Publish to GitLab Container Registry
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: |
make publish TAG=edge SKIP_BUILD=true SKIP_TESTS=true

0 comments on commit 7e379a0

Please sign in to comment.