summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/sops/.github/workflows/import-galaxy.yml
blob: ae472845d257d4da68207a4e59985efe74a59f20 (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
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

name: import-galaxy
on:
  # Run CI against all pushes (direct commits, also merged PRs) to main, and all Pull Requests
  push:
    branches:
      - main
      - stable-*
  pull_request:

env:
  # Adjust this to your collection
  NAMESPACE: community
  COLLECTION_NAME: sops

jobs:
  build-collection:
    name: Build collection artifact
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3
        with:
          path: ./checkout

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'

      - name: Install ansible-core
        run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check

      - name: Make sure galaxy.yml has version entry
        run: >-
          python -c
          'import yaml ;
          f = open("galaxy.yml", "rb") ;
          data = yaml.safe_load(f) ;
          f.close() ;
          data["version"] = data.get("version") or "0.0.1" ;
          f = open("galaxy.yml", "wb") ;
          f.write(yaml.dump(data).encode("utf-8")) ;
          f.close() ;
          '
        working-directory: ./checkout

      - name: Build collection
        run: ansible-galaxy collection build
        working-directory: ./checkout

      - name: Copy artifact into subdirectory
        run: mkdir ./artifact && mv ./checkout/${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-*.tar.gz ./artifact

      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-${{ github.sha }}
          path: ./artifact/

  import-galaxy:
    name: Import artifact with Galaxy importer
    runs-on: ubuntu-latest
    needs:
      - build-collection
    steps:
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'

      - name: Install ansible-core
        run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check

      - name: Install galaxy-importer
        run: pip install galaxy-importer --disable-pip-version-check

      - name: Download artifact
        uses: actions/download-artifact@v3
        with:
          name: ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-${{ github.sha }}

      - name: Run Galaxy importer
        run: python -m galaxy_importer.main ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-*.tar.gz