summaryrefslogtreecommitdiffstats
path: root/.github/workflows/stage.yml
blob: 1e6f8e5fd6341132219c75753710ba366faa141e (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
---
name: Stage Release

env:
  LC_ALL: "C.UTF-8" # prevent ERROR: Ansible could not initialize the preferred locale: unsupported locale setting

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'AWX version.'
        required: true
        default: ''
      operator_version:
        description: 'Operator version. Leave blank to skip staging awx-operator.'
        default: ''
      confirm:
        description: 'Are you sure? Set this to yes.'
        required: true
        default: 'no'

jobs:
  stage:
    if: endsWith(github.repository, '/awx')
    runs-on: ubuntu-latest
    timeout-minutes: 90
    permissions:
      packages: write
      contents: write
    steps:
      - name: Verify inputs
        run: |
          set -e

          if [[ ${{ github.event.inputs.confirm }} != "yes" ]]; then
            >&2 echo "Confirm must be 'yes'"
            exit 1
          fi

          if [[ ${{ github.event.inputs.version }} == "" ]]; then
            >&2 echo "Set version to continue."
            exit 1
          fi

          exit 0

      - name: Checkout awx
        uses: actions/checkout@v4
        with:
          show-progress: false
          path: awx

      - name: Checkout awx-operator
        uses: actions/checkout@v4
        with:
          show-progress: false
          repository: ${{ github.repository_owner }}/awx-operator
          path: awx-operator

      - name: Checkout awx-logos
        uses: actions/checkout@v4
        with:
          show-progress: false
          repository: ansible/awx-logos
          path: awx-logos

      - name: Get python version from Makefile
        working-directory: awx
        run: echo py_version=`make PYTHON_VERSION` >> $GITHUB_ENV

      - name: Install python ${{ env.py_version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ env.py_version }}

      - name: Install playbook dependencies
        run: |
          python3 -m pip install docker

      - name: Log into registry ghcr.io
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Copy logos for inclusion in sdist for official build
        working-directory: awx
        run: |
          cp ../awx-logos/awx/ui/client/assets/* awx/ui/public/static/media/

      - name: Setup node and npm for new UI build
        uses: actions/setup-node@v2
        with:
          node-version: '18'

      - name: Prebuild new UI for awx image (to speed up build process)
        working-directory: awx
        run: make ui

      - name: Set build env variables
        run: |
          echo "DEV_DOCKER_TAG_BASE=ghcr.io/${OWNER,,}" >> $GITHUB_ENV
          echo "COMPOSE_TAG=${{ github.event.inputs.version }}" >> $GITHUB_ENV
          echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
          echo "AWX_TEST_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
          echo "AWX_TEST_IMAGE=ghcr.io/${OWNER,,}/awx" >> $GITHUB_ENV
          echo "AWX_EE_TEST_IMAGE=ghcr.io/${OWNER,,}/awx-ee:${{ github.event.inputs.version }}" >> $GITHUB_ENV
          echo "AWX_OPERATOR_TEST_IMAGE=ghcr.io/${OWNER,,}/awx-operator:${{ github.event.inputs.operator_version }}" >> $GITHUB_ENV
        env:
          OWNER: ${{ github.repository_owner }}

      - name: Build and stage AWX
        working-directory: awx
        env:
          DOCKER_BUILDX_PUSH: true
          HEADLESS: false
          PLATFORMS: linux/amd64,linux/arm64
        run: |
          make awx-kube-buildx

      - name: tag awx-ee:latest with version input
        run: |
          docker buildx imagetools create \
            quay.io/ansible/awx-ee:latest \
            --tag ${AWX_EE_TEST_IMAGE}

      - name: Stage awx-operator image
        working-directory: awx-operator
        run: |
          BUILD_ARGS="--build-arg DEFAULT_AWX_VERSION=${{ github.event.inputs.version}} \
              --build-arg OPERATOR_VERSION=${{ github.event.inputs.operator_version }}" \
          IMG=${AWX_OPERATOR_TEST_IMAGE} \
          make docker-buildx

      - name: Pulling images for test deployment with awx-operator
        # awx operator molecue test expect to kind load image and buildx exports image to registry and not local
        run: |
          docker pull -q ${AWX_OPERATOR_TEST_IMAGE}
          docker pull -q ${AWX_EE_TEST_IMAGE}
          docker pull -q ${AWX_TEST_IMAGE}:${AWX_TEST_VERSION}

      - name: Run test deployment with awx-operator
        working-directory: awx-operator
        run: |
          python3 -m pip install -r molecule/requirements.txt
          ansible-galaxy collection install -r molecule/requirements.yml
          sudo rm -f $(which kustomize)
          make kustomize
          KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule test -s kind

      - name: Create draft release for AWX
        working-directory: awx
        run: |
          ansible-playbook -v tools/ansible/stage.yml \
            -e repo=${{ github.repository }} \
            -e awx_image=ghcr.io/${{ github.repository }} \
            -e version=${{ github.event.inputs.version }} \
            -e github_token=${{ secrets.GITHUB_TOKEN }}

      - name: Create draft release for awx-operator
        if: ${{ github.event.inputs.operator_version != '' }}
        working-directory: awx
        run: |
          ansible-playbook tools/ansible/stage.yml \
            -e version=${{ github.event.inputs.operator_version }} \
            -e repo=${{ github.repository_owner }}/awx-operator \
            -e github_token=${{ secrets.AWX_OPERATOR_RELEASE_TOKEN }}