Skip to content

Commit

Permalink
try docker hub
Browse files Browse the repository at this point in the history
  • Loading branch information
ji-podhead committed Aug 4, 2024
1 parent c0dc9dc commit 74fb523
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 44 deletions.
75 changes: 31 additions & 44 deletions .github/workflows/galaxy_build.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,40 @@
name: Publish Ansible Galaxy Collection
name: Build and Push Docker Image

on:
push:
branches:
- main # Ändern Sie dies entsprechend Ihrem Hauptbranch
on: [push]

jobs:

uild-and-publish:
build-and-push:
runs-on: ubuntu-latest
permissions: write-all


steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: test
run: |
python ./utils/python/parse_json.py ./plugin_requirements.json
- name: Get current commit ID
run: echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Get previous commit ID
run: |
PREV_COMMIT_ID=$(git rev-list --max-parents=0 HEAD | head -n 1)
echo "PREV_COMMIT_ID=$PREV_COMMIT_ID" >> $GITHUB_ENV
- name: Check if requirements have changed
id: check_changes
run: |
# Überprüfen Sie, ob sich plugin_requirements.yml geändert hat
dif=
echo $dif
CHANGED=$(git diff HEAD 'plugin_requirements.yml')
if [ -z "$CHANGED" ]; then
else
echo "CHANGED=false" >> $GITHUB_ENV
fi
- name: Fetch Vault Secret
id: fetch-vault-secret
uses: hashicorp/vault-action@v2
with:
url: http://localhost:8200
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
/v1/keyvalue/data/docker/hub pass | DOCKER_HUB_ACCESS_TOKEN ;
/v1/keyvalue/data/docker/hub user | DOCKER_HUB_USERNAME ;
# - name: Build collection
# run: ansible-galaxy collection build -vvv --output-path . --requirements-file requirements.txt --force
# env:
# ANSIBLE_GALAXY_API_KEY: ${{ secrets.GALAXY_API_KEY }} # Stellen Sie sicher, dass GALAXY_API_KEY in Ihren Secrets gesetzt ist
#
# - name: Publish collection
# run: ansible-galaxy collection publish --api-key ${{ secrets.GALAXY_API_KEY }} ./ji_podhead-ilohelper-*.tar.gz
# env:
# ANSIBLE_GALAXY_API_KEY: ${{ secrets.GALAXY_API_KEY }}
- name: Set environment variables
run: |
echo "DOCKER_HUB_USERNAME=${{ steps.fetch-vault-secret.outputs.secrets.DOCKER_HUB_USERNAME }}" >> $GITHUB_ENV
echo "DOCKER_HUB_ACCESS_TOKEN=${{ steps.fetch-vault-secret.outputs.secrets.DOCKER_HUB_ACCESS_TOKEN }}" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_ACCESS_TOKEN }}

- name: Push Docker Image
uses: docker/push-action@v2
with:
login-server: docker.io
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_ACCESS_TOKEN }}
tags: user/my-docker-image:latest
53 changes: 53 additions & 0 deletions utils/bash/old/galaxy_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish Ansible Galaxy Collection

on:
push:
branches:
- main # Ändern Sie dies entsprechend Ihrem Hauptbranch

jobs:

uild-and-publish:
runs-on: ubuntu-latest
permissions: write-all

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: test
run: |
python ./utils/python/parse_json.py ./plugin_requirements.json
- name: Get current commit ID
run: echo "COMMIT_ID=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Get previous commit ID
run: |
PREV_COMMIT_ID=$(git rev-list --max-parents=0 HEAD | head -n 1)
echo "PREV_COMMIT_ID=$PREV_COMMIT_ID" >> $GITHUB_ENV
- name: Check if requirements have changed
id: check_changes
run: |
# Überprüfen Sie, ob sich plugin_requirements.yml geändert hat
dif=
echo $dif
CHANGED=$(git diff HEAD 'plugin_requirements.yml')
if [ -z "$CHANGED" ]; then
else
echo "CHANGED=false" >> $GITHUB_ENV
fi
# - name: Build collection
# run: ansible-galaxy collection build -vvv --output-path . --requirements-file requirements.txt --force
# env:
# ANSIBLE_GALAXY_API_KEY: ${{ secrets.GALAXY_API_KEY }} # Stellen Sie sicher, dass GALAXY_API_KEY in Ihren Secrets gesetzt ist
#
# - name: Publish collection
# run: ansible-galaxy collection publish --api-key ${{ secrets.GALAXY_API_KEY }} ./ji_podhead-ilohelper-*.tar.gz
# env:
# ANSIBLE_GALAXY_API_KEY: ${{ secrets.GALAXY_API_KEY }}

0 comments on commit 74fb523

Please sign in to comment.